コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequiredValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <returns></returns>
 public static RequiredValidator CreateValidator(Type type, string propertyName)
 {
     return(new RequiredValidator(Validator.GetPropertyInfo(type, propertyName)));
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotEmptyValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <returns></returns>
 public static NotNullValidator CreateValidator(Type type, string propertyName)
 {
     return(new NotNullValidator(Validator.GetPropertyInfo(type, propertyName)));
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="methodName">
 /// Name of the method.  This method must conform to the Predicate[of T]
 /// signature where T is the property type this attribute has been placed on.
 /// </param>
 /// <returns></returns>
 public static CustomValidator CreateValidator(Type type, string errorMessage, string propertyName, string methodName)
 {
     return(new CustomValidator(errorMessage, Validator.GetPropertyInfo(type, propertyName), methodName));
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LengthValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="minLength">The minimum value.</param>
 /// <param name="maxLength">The maximum value.</param>
 /// <returns></returns>
 public static LengthValidator CreateValidator(Type type, string errorMessage, string propertyName, int minLength, int maxLength)
 {
     return(new LengthValidator(errorMessage, Validator.GetPropertyInfo(type, propertyName), minLength, maxLength));
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RangeValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="minValue">The minimum value.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <returns></returns>
 public static RangeValidator CreateValidator(Type type, string errorMessage, string propertyName, object minValue, object maxValue)
 {
     return(new RangeValidator(errorMessage, Validator.GetPropertyInfo(type, propertyName), minValue, maxValue));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompareValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="comparisonOperator">The comparison operator.</param>
 /// <param name="valueToCompare">The value to compare.</param>
 /// <returns></returns>
 public static CompareValidator CreateValidator(Type type, string errorMessage, string propertyName, ComparisonOperator comparisonOperator, object valueToCompare)
 {
     return(new CompareValidator(errorMessage, Validator.GetPropertyInfo(type, propertyName), comparisonOperator, valueToCompare));
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RegexValidator"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="regex">The regular expression.</param>
 /// <returns></returns>
 public static RegexValidator CreateValidator(Type type, string propertyName, string regex)
 {
     return(new RegexValidator(Validator.GetPropertyInfo(type, propertyName), regex));
 }