Open kyrias opened 4 months ago
Yeah I noticed that when fixing bugs last weekend. That sounds like a bug imo
Given that the tests were changed to work with the new structure it seemed intentional to me:
Yes but I didn't notice that so I'd want to revert to the previous behaviour.
cc @pintariching
So I'm thinking of requiring #[validate(nested)]
rather than just #[validate]
for nested validation to be explicit on the field (not on the struct). The reason to require the nested
part is that it allows giving better error message if you use only #[validate]
.
What do you think?
So I'm thinking of requiring
#[validate(nested)]
rather than just#[validate]
for nested validation to be explicit on the field (not on the struct). The reason to require thenested
part is that it allows giving better error message if you use only#[validate]
.What do you think?
I'm fine with that.
I think this is fixed in https://github.com/Keats/validator/pull/304 Hacky fix but the whole error system will be rewritten for 0.19 so i don't want to spend time on it.
Can people try this branch?
Seems to work as expected, and +1 on the compile error telling you what to do.
It seems like the new derive implementation completely changed what's necessary for nested validations to work in a way where what previously worked now fails completely silently and there is no mention of this in the changelog. Additionally, the README still recommends the old way which silently fails.
The README still says to just slap
#[validate]
on a field for nested validation, which now does nothing at all, and that the following structs would return validation errors if there's something wrong in either theContactDetails
orPreference
structs, which is no longer the case. Apparently you need to both slap a#[validate(nested)]
on the actual child type that you want the validation to nest into and on the field in the parent struct. This is rather confusing and completely undiscoverable, and if you just add#[validate(nested)]
to the field you get a completely opaque compiler error.