Validation Attributes

‘Required If’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System; using System.ComponentModel.DataAnnotations; using System.Globalization; /// <summary> /// Provides conditional validation based on related property value. /// ...
Read More

‘Numeric Greater Than’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System.ComponentModel.DataAnnotations; public class NumericGreaterThanAttribute : ValidationAttribute { private readonly string otherPropertyName; public NumericGreaterThanAttribute(string otherPropertyName) { this.otherPropertyName = ...
Read More

‘Must Be Checked’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System; using System.ComponentModel.DataAnnotations; public class MustBeCheckedAttribute : ValidationAttribute { public override bool IsValid(object value) { if (value ...
Read More

‘Minimum Elements’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System.Collections; using System.ComponentModel.DataAnnotations; public class MinimumElementsAttribute : ValidationAttribute { private readonly int minElements; public MinimumElementsAttribute(int minElements) { ...
Read More

‘Date Less Than’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; public class DateLessThanAttribute : ValidationAttribute, IClientValidatable { private readonly string ...
Read More

‘At Least One True’ Validation Attribute

namespace ALeonJ.ValidationAttributes { using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Mvc; public class AtLeastOneTrueAttribute : ValidationAttribute, IClientValidatable { public AtLeastOneTrueAttribute(string otherPropertyNames) ...
Read More