Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return useful information #278

Open
Alphapage opened this issue Oct 27, 2023 · 5 comments
Open

Return useful information #278

Alphapage opened this issue Oct 27, 2023 · 5 comments

Comments

@Alphapage
Copy link

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.

@Keats
Copy link
Owner

Keats commented Oct 28, 2023

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

@Alphapage
Copy link
Author

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

@Keats
Copy link
Owner

Keats commented Oct 29, 2023

why would it throw an error?

@pintariching
Copy link
Contributor

pintariching commented Oct 29, 2023

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.

@Keats
Copy link
Owner

Keats commented Oct 30, 2023

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants