Search code examples
c#validationdata-annotations

Data Annotations for multiple validation types


I feel like this should be so simple. I need to validate a decimal value with a range of (0 - 99.999999) OR I need to be able to mark the value with "TBD". I have no way to change that requirement or I may have done it another way. Is there a way to handle multiple validation types through data annotations? I suck at regex. If this can be done that way, can anyone point me in the right direction?


Solution

  • So, Jerodev was correct. This could not be properly done with a Data Annotation. I had to create a custom validator and then implement the validator in a new Data Annotation of my own. I followed http://ezzylearning.com/tutorial/creating-custom-validation-attribute-in-asp-net-mvc to learn how to create my own custom validator.