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

Forced field validation when the field is empty? #53

Closed
vsilent opened this issue Jan 23, 2024 · 1 comment
Closed

Forced field validation when the field is empty? #53

vsilent opened this issue Jan 23, 2024 · 1 comment

Comments

@vsilent
Copy link

vsilent commented Jan 23, 2024

It looks like field is validated anyway, even it's wrapped with the Option, is it default behaviour or a bug?
for example:

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
pub struct Port {
    #[validate(pattern = r"^\d{2,6}+$")]
    pub host_port: Option<String>,

I expected this field not to be validated when empty or should I use rules for that case ?

@vsilent
Copy link
Author

vsilent commented Jan 23, 2024

Sorry my bad, not an issue, because I get Some("") not None

@vsilent vsilent closed this as completed Jan 23, 2024
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

1 participant