Simon Ziegler
Simon Ziegler

Reputation: 25

Blazor form failing validation due to items in the data model that are not shown in the form

I have a Blazor (server side) project that uses a couple of EditForms. In each case the data model happens to include a nested object that is not needed in the form. I find that the form will fail validation if that object is deemed invalid, but without any explanation. Is there a way that I can examine the form's specific reason for deciding that a submit event is invalid?

Thanks!

Upvotes: 1

Views: 946

Answers (1)

Alexander
Alexander

Reputation: 151

Simon, check this information microsoft docs, about

ObjectGraphDataAnnotationsValidator, ValidateComplexType

When you put attribute(ValidateComplexType) on your nested objects and replace "DataAnnotationsValidator" with "ObjectGraphDataAnnotationsValidator " you will see the error information for your nested objects, after everything in your primary edit form is valid.

Upvotes: 1

Related Questions