/// <summary> /// Initializes a new instance of the <see cref="BetweenValidator"/> class. /// </summary> /// <param name="from">From.</param> /// <param name="to">The automatic.</param> public BetweenValidator(IComparable @from, IComparable to) { if (@from == null) { throw new ArgumentNullException("from"); } if (to == null) { throw new ArgumentNullException("to"); } if (!to.GetType().IsInstanceOfType(@from)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "'To' value should be type of '{0}'", @from.GetType().FullName)); } if (to.CompareTo(@from) == -1) { throw new ArgumentOutOfRangeException("to", "'To' should be larger than 'from'."); } m_From = @from; m_To = to; m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.FROM_VALUE, FromValue }, { Constants.ValidationMessageParameterNames.TO_VALUE, ToValue } }; }
/// <summary> /// Initializes a new instance of the <see cref="EqualToEntityPropertyValidator"/> class. /// </summary> /// <param name="memberToCompareFunc">The member to compare function.</param> /// <param name="member">The member.</param> /// <param name="ownerType">The owner type.</param> /// <param name="confirmProperty">if set to <c>true</c> [confirm property].</param> /// <param name="comparer">The comparer.</param> /// <exception cref="System.ArgumentNullException"> /// memberToCompareFunc /// or /// member /// or /// ownerType /// </exception> public EqualToEntityPropertyValidator(Func <object, object> memberToCompareFunc, MemberInfo member, Type ownerType, bool confirmProperty = true, IEqualityComparer comparer = null) { if (memberToCompareFunc == null) { throw new ArgumentNullException("memberToCompareFunc"); } if (member == null) { throw new ArgumentNullException("member"); } if (ownerType == null) { throw new ArgumentNullException("ownerType"); } OwnerType = ownerType; m_MemberToCompareFunc = memberToCompareFunc; m_MemberToCompareMemberInfo = member; m_ConfirmProperty = confirmProperty; m_Comparer = comparer; m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.MEMBER_TO_COMPARE_MEMBER_INFO, m_MemberToCompareMemberInfo }, { Constants.ValidationMessageParameterNames.OWNER_TYPE, ownerType } }; }
/// <summary> /// Initializes a new instance of the <see cref="PredicateValidator"/> class. /// </summary> /// <param name="predicate">The predicate.</param> /// <exception cref="System.ArgumentNullException">predicate</exception> public PredicateValidator(Predicate <object> predicate) { if (predicate == null) { throw new ArgumentNullException("predicate"); } m_Predicate = predicate; m_ValidatorProperties = new ValidatorProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="NotEqualToValidator"/> class. /// </summary> /// <param name="valueToCompare">The value to compare.</param> /// <param name="comparer">The comparer.</param> /// <exception cref="System.ArgumentNullException">valueToCompare</exception> public NotEqualToValidator(object valueToCompare, IEqualityComparer comparer = null) { if (valueToCompare == null) { throw new ArgumentNullException("valueToCompare"); } m_EqualToValidator = new EqualToValidator(valueToCompare, comparer); m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.VALUE_TO_COMPARE, ValueToCompare } }; }
/// <summary> /// Initializes a new instance of the <see cref="GreaterThanValidator"/> class. /// </summary> /// <param name="valueToCompare">The value to compare.</param> /// <exception cref="System.ArgumentNullException">valueToCompare</exception> public GreaterThanValidator(IComparable valueToCompare) { if (valueToCompare == null) { throw new ArgumentNullException("valueToCompare"); } m_ValueToCompare = valueToCompare; m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.VALUE_TO_COMPARE, ValueToCompare } }; }
/// <summary> /// Initializes a new instance of the <see cref="RegexValidator"/> class. /// </summary> /// <param name="validationMessageResourceName">Name of the validation message resource.</param> /// <param name="expression">The expression.</param> /// <param name="regexOptions">The regex options.</param> /// <exception cref="System.ArgumentNullException">expression</exception> public RegexValidator(string validationMessageResourceName, string expression, RegexOptions regexOptions = RegexOptions.None) { if (validationMessageResourceName == null) { throw new ArgumentNullException("validationMessageResourceName"); } if (expression == null) { throw new ArgumentNullException("expression"); } m_Regex = new Regex(expression, RegexOptions.Compiled | regexOptions); m_ValidationMessageResourceName = validationMessageResourceName; m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.REGEX, expression } }; }
/// <summary> /// Initializes a new instance of the <see cref="LengthValidator"/> class. /// </summary> /// <param name="min">The minimum.</param> /// <param name="max">The maximum.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// min;Min should be larger than -1. /// or /// max;Max should be larger than min. /// </exception> public LengthValidator(int min, int max = -1) { if (min < 0) { throw new ArgumentOutOfRangeException("min", "Min should be larger than -1."); } if (max != -1 && max < min) { throw new ArgumentOutOfRangeException("max", "Max should be larger than min."); } m_Min = min; m_Max = max; m_ValidatorProperties = new ValidatorProperties { { Constants.ValidationMessageParameterNames.MIN, Min }, { Constants.ValidationMessageParameterNames.MAX, Max } }; }
/// <summary> /// Initializes a new instance of the <see cref="CreditCardValidator"/> class. /// </summary> public CreditCardValidator() { m_ValidatorProperties = new ValidatorProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="NotNullValidator"/> class. /// </summary> public NotNullValidator() { m_ValidatorProperties = new ValidatorProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="NotEmptyValidator"/> class. /// </summary> public NotEmptyValidator() { m_ValidatorProperties = new ValidatorProperties(); }