must_match validator error
Closed this issue · 1 comments
odra commented
Hello,
I am trying to use the must_match
validator function based on what's documented in the readme file:
#[derive(Debug, Validate, Deserialize)]
pub struct Header {
#[validate(must_match = "00")]
pub register_type: String
}
Compling the above code leads to the following error:
error: Invalid argument for `must_match` validator of field `register_type`: the other field doesn't exist in struct
--> src/lib/b3/equities/types/header.rs:13:5
|
13 | #[validate(must_match = "00")]
| ^
I tried other validator functions such as the regex one and it worked ok.
Am I missing something?
Validator version: 0.15
Keats commented
As mentioned in the docs (https://github.com/Keats/validator#must_match), must_match
must refer to another field in the struct, not an arbitrary value.
There is a regex validator in case you need to validate the content of a string