Keats/validator

Return useful information

Opened this issue · 5 comments

Hello,

It seems validate() only return () which is not very helpful.
Is it possible to return the validator fields count ?
It will then be possible to check if no validator was added to the struct and show an error for example in that case.

Thank you in advance for your answers.

I'm not sure it makes sense? With a function called validate I don't expect anything in particular in the Ok branch

Does it throw any error when no validation fields are added to the struct ?

why would it throw an error?

I think they want the macro to throw an error if you have a struct with #[derive(Validate)] on it, but none of the fields have a #[validate] tag on it. I'm not sure how usefull this would be, but this could be a compile error instead.

A compile error would be fine but then you need to handle Validate with nested and check whether that other struct has some validation set up..