简体   繁体   中英

MVC2 Model Validation - Require at least one

I have a model, EventSearch defined and I'm stumped on how to create a validator that will require at least one field to be filled for the model to be considered valid. It seems to me this will either be a model annotation or I could annotate each property as belonging to a group of "Require At Least One". Anybody run into this before?

Check out these links on how to create custom data annotations by extending from the ValidationAttribute class:

Custom model validation of dependent properties using Data Annotations

Custom Validation Attribute MVC2

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