Developers, Technology Evangelists, Bros.

MVC Validation Extensions 1.1.2 Released

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; }
mvc validation extensions 1.1.2

Not required because the control is empty.

mvc validation extensions 1.1.2

Not required because the value in the control does not meet the criteria.

mvc validation extensions 1.1.2

Required and invalid.

mvc validation extensions 1.1.2

Required and valid.

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!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.