I’m pleased to release another update to my MVC Validation Extensions. This update is once again focused on adding more functionality to the package via the following validation attribute:
- RequiredIfAnyValue
This attribute builds upon the previous update where we created required fields based on another field’s value. Now we are able to require a field if another field is on of many potential values. Usage of the attribute is quite simple just like the other attributes.
Example Usage
[RequiredIfAnyValue("RequiredIfAnyValueControl", new []{"ValOne", "ValTwo", "ValThree"})] public int? RequiredIfAnyValue { get; set; } public string RequiredIfAnyValueControl { get; set; }
For more details and examples head on over to the MVC Validation Extensions project page or head on over to nuget and download the updated package.
More To Come
There are a few more attributes that I intend to add to the package in the near future: RequireOne (useful for checkboxes or multi-selects) and NotEqualTo. I’d love to hear of any more suggestions for other MVC validation attributes that you’ve either written yourself or ones that would be useful for in your projects!
Lastly, I am planning to release the full source on Github as soon as possible. Happy Validating!