简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM