Open matous-volf opened 3 weeks ago
@matous-volf I think validate(nested)
is meant for struct and not enum. What are you trying to achieve?
@RabidFire
I would like to both sanitize and validate a struct, for instance the User
. So my goal is basically:
#[derive(Sanitize, Validate)]
struct User {
#[sanitize]
pub kind: UserKind,
#[validate(range(min = 18))]
pub age: u32,
... other fields to sanitize and validate
}
But that won't compile, as shown above.
I don't necessarily need to validate the enum field (here kind
), I just need to sanitize it. If I understand correctly, that should be possible because UserKind
implements sanitizer::Sanitize
.
This does work:
However, after deriving from validator's
Validate
:I get
This, I suppose, should not happen. Either way, even when following the instruction:
the error persists.
Maybe the issue is on the validator's side – I have no idea how derive macros work. Thanks in advance.