yassun7010/serde_valid

Forced field validation when the field is empty?

vsilent opened this issue · 1 comments

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 ?

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