You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kevin Sigmund @ksigmund Mar 26 08:49
If I have a custom ValidationAttribute that returns false, will the error naturally be returned in the result from the controller, or do I need to override PostAsync, check the ModelState, etc.?
Kevin Sigmund @ksigmund Mar 26 09:22
Basically I'm just looking to do simple model validation, but it doesn't seem that when my model is invalid that the failure is respected.
Jared Nance @jaredcnance Mar 26 10:05
We do not currently check ModelState.IsValid ... I don't want to make any assumptions about how model validation is implemented. However, I'm open to discussion and with a little more information I think it may be reasonable to do that in the library automatically (while providing some form of escape hatch). My main concern would be around not making any breaking changes without good reason.
Kevin Sigmund @ksigmund Mar 26 10:09
Right now it seems that the framework is fairly optimistic about the state of the model right? i.e. without any additional logic, failures are ignored essentially.
Jared Nance @jaredcnance Mar 26 10:12
As long as it passes de-serialization, we perform no further model validations. That said, we also shouldn't be preventing any model validations in custom controllers. Is model validation something you believe should be handled by the framework by default?
Kevin Sigmund @ksigmund Mar 26 10:16
I think so - and I believe that's the way that the .NET Core framework is moving as well.
It seems like if I have a [Required] or [SomeOtherValidation] attribute if the validation fails, something is wrong and I probably don't want to ignore that. Maybe it's some sort of config at setup where we could instruct the framework to respect validations.
Gitter transcript:
The text was updated successfully, but these errors were encountered: