Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder for Validation? #327

Open
rakshith-ravi opened this issue Sep 8, 2023 · 5 comments
Open

Builder for Validation? #327

rakshith-ravi opened this issue Sep 8, 2023 · 5 comments

Comments

@rakshith-ravi
Copy link

Would you be open to a builder pattern for the Validation struct? Right now, I'm using it like so:

jsonwebtoken::decode(
	token,
	&DecodingKey::from_secret(config.jwt_secret),
	{
		let mut validation = Validation::default();

		validation.validate_exp = false;
		validation.validate_nbf = false;

		&validation
	}
);

Would be nice to have a builder pattern for validaton that we can use declaratively

@rakshith-ravi
Copy link
Author

I'd be happy to put a PR for this if you're open to it

@Keats
Copy link
Owner

Keats commented Sep 8, 2023

I don't really want a builder for it no

@rakshith-ravi
Copy link
Author

Got it. How about a mutable function to set those variables? Similar to set_audience and set_issuer? That way we can do Validation::default().should_validate_exp(bool)

@Keats
Copy link
Owner

Keats commented Sep 11, 2023

Isn't that a builder?

@rakshith-ravi
Copy link
Author

Yes, but without using a new struct for it. Shouldn't increase the compile times in any way, and also follows the existing convention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants