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
IValidatableObject.Validate Only Called If Attribute-Defined Validation Rules Pass? #1899
Comments
This issue is being closed because it has not been updated in 3 months. We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate. |
I am experiencing this behavior as well in Asp.Net Core 2.0, with a referenced library containing an |
This is really annoying bug. Why close it? Its hard to architect things and tell people dataannotations work then you find IValidatableObject.Validate runs as per above. It's an issue and this SHOULD be reopened. Meanwhile I have to deal with programmers who think this is good programming:
|
Hello,
I have an object with a
[Required]
-decorated property that implementsIValidatableObject
. During model binding, if the required property is null, the object'sValidate()
method is never called. IsValidate()
only called if attribute-configured validation passes?In my case, if a user submits a form with validation errors, they first see a message about the missing field. Then, once that error has been resolved and the form resubmitted, they are presented with an additional list of errors—this time, produced by
Validate()
. Is there a way to trigger all validation to occur at the same time so that the user is presented with a list of all errors needing their attention when they first submit the form?Thanks,
Ben
Versions: ASP.Net Core 1.1.0/.Net 4.6.1
Example Code
From the controller:
If the user fails to populate the required field, they'll see an error message about it but they won't see the other error messages that Validate() might add.
The text was updated successfully, but these errors were encountered: