Closed weiztech closed 1 year ago
I think you need to call validate()
on the deserialized User
struct in the match statement. Or if you want a one-liner try
let validation_result = serde_json::from_str::<User>(data).is_ok_and(|user| user.validate());
Not entirely sure if this will work.
since it's not possible to validate directly using serde_json::from_str
, I also think should use validate
method for now. Thanks
I'm trying to use
validator
but it seems it does not trigger the validation and always returns success result.depedencies
Code
is it possible to trigger the validation when using
serde_json::from_str
?