コード例 #1
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="DomainValidatorAttribute"/>.</para>
        /// </summary>
        /// <param name="domain">List of values to be used in the validation.</param>
        public DomainValidatorAttribute(params object[] domain)
            : base()
        {
            ValidatorArgumentsValidatorHelper.ValidateDomainValidator(domain);

            this.domain = domain;
        }
コード例 #2
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="EnumConversionValidator"/>.</para>
        /// </summary>
        /// <param name="enumType">The enum type to check if the string can be converted.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        public EnumConversionValidator(Type enumType, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateEnumConversionValidator(enumType);

            this.enumType = enumType;
        }
コード例 #3
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="TypeConversionValidator"/>.</para>
        /// </summary>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="targetType">The supplied type used to determine if the string can be converted to it.</param>
        public TypeConversionValidator(Type targetType, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateTypeConversionValidator(targetType);

            this.targetType = targetType;
        }
コード例 #4
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="ContainsCharactersValidatorAttribute"/> </para>
        /// </summary>
        /// <param name="characterSet">The character set to be evaluated.</param>
        /// <param name="containsCharacters">The mode to evaluate the character set.</param>
        public ContainsCharactersValidatorAttribute(string characterSet, ContainsCharacters containsCharacters)
        {
            ValidatorArgumentsValidatorHelper.ValidateContainsCharacterValidator(characterSet);

            this.characterSet       = characterSet;
            this.containsCharacters = containsCharacters;
        }
コード例 #5
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="DomainValidator{T}"/>.</para>
        /// </summary>
        /// <param name="domain">List of values to be used in the validation.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        public DomainValidator(IEnumerable <T> domain, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateDomainValidator(domain);

            this.domain = domain;
        }
コード例 #6
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="ContainsCharactersValidator"/>.</para>
        /// </summary>
        /// <param name="characterSet">The string containing the set of allowed characters.</param>
        /// <param name="containsCharacters">The <see cref="ContainsCharacters"/> specifying the kind of character matching behavior.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="negated">Indicates if the validation logic represented by the validator should be negated.</param>
        public ContainsCharactersValidator(string characterSet, ContainsCharacters containsCharacters, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateContainsCharacterValidator(characterSet);

            this.characterSet       = characterSet;
            this.containsCharacters = containsCharacters;
        }
コード例 #7
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RegexValidatorAttribute"/> class with a regex pattern,
        /// matching options and a failure message template.</para>
        /// </summary>
        /// <param name="pattern">The pattern to match.</param>
        /// <param name="patternResourceName">The resource name containing the pattern for the regular expression.</param>
        /// <param name="patternResourceType">The type containing the resource for the regular expression.</param>
        /// <param name="options">The <see cref="RegexOptions"/> to use when matching.</param>
        internal RegexValidatorAttribute(string pattern, string patternResourceName, Type patternResourceType, RegexOptions options)
        {
            ValidatorArgumentsValidatorHelper.ValidateRegexValidator(pattern, patternResourceName, patternResourceType);

            this.pattern             = pattern;
            this.options             = options;
            this.patternResourceName = patternResourceName;
            this.patternResourceType = patternResourceType;
        }
コード例 #8
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RangeValidator{T}"/> class with fully specified
        /// bound constraints and a message template.</para>
        /// </summary>
        /// <param name="lowerBound">The lower bound.</param>
        /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param>
        /// <param name="upperBound">The upper bound.</param>
        /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        /// <seealso cref="RangeBoundaryType"/>
        public RangeValidator(T lowerBound, RangeBoundaryType lowerBoundType,
                              T upperBound, RangeBoundaryType upperBoundType,
                              string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateRangeValidator(lowerBound, lowerBoundType, upperBound, upperBoundType);

            this.rangeChecker = new RangeChecker <T>(lowerBound, lowerBoundType, upperBound, upperBoundType);
        }
コード例 #9
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RegexValidator"/> class with a regex pattern,
        /// matching options and a failure message template.</para>
        /// </summary>
        /// <param name="pattern">The pattern to match.</param>
        /// <param name="options">The <see cref="RegexOptions"/> to use when matching.</param>
        /// <param name="messageTemplate">The message template.</param>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        /// <param name="patternResourceName">The resource name containing the pattern for the regular expression.</param>
        /// <param name="patternResourceType">The type containing the resource for the regular expression.</param>
        public RegexValidator(string pattern, string patternResourceName, Type patternResourceType, RegexOptions options, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateRegexValidator(pattern, patternResourceName, patternResourceType);

            this.pattern             = pattern;
            this.options             = options;
            this.patternResourceName = patternResourceName;
            this.patternResourceType = patternResourceType;
        }
コード例 #10
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidatorAttribute"/>.</para>
        /// </summary>
        /// <param name="lowerBound">The lower bound.</param>
        /// <param name="lowerUnit">The lower bound unit of time.</param>
        /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param>
        /// <param name="upperBound">The upper bound</param>
        /// <param name="upperUnit">The upper bound unit of time.</param>
        /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param>
        public RelativeDateTimeValidatorAttribute(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType,
                                                  int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType)
        {
            ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType);

            this.lowerBound     = lowerBound;
            this.lowerUnit      = lowerUnit;
            this.lowerBoundType = lowerBoundType;
            this.upperBound     = upperBound;
            this.upperUnit      = upperUnit;
            this.upperBoundType = upperBoundType;
        }
コード例 #11
0
        private RangeValidatorAttribute(
            Type boundType,
            object lowerBound, IComparable effectiveLowerBound, RangeBoundaryType lowerBoundType,
            object upperBound, IComparable effectiveUpperBound, RangeBoundaryType upperBoundType)
        {
            ValidatorArgumentsValidatorHelper.ValidateRangeValidator(effectiveLowerBound, lowerBoundType, effectiveUpperBound, upperBoundType);

            this.boundType           = boundType;
            this.lowerBound          = lowerBound;
            this.effectiveLowerBound = effectiveLowerBound;
            this.lowerBoundType      = lowerBoundType;
            this.upperBound          = upperBound;
            this.effectiveUpperBound = effectiveUpperBound;
            this.upperBoundType      = upperBoundType;
        }
コード例 #12
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="RelativeDateTimeValidator"/>.</para>
        /// </summary>
        /// <param name="negated">True if the validator must negate the result of the validation.</param>
        /// <param name="messageTemplate">The message template to use when logging results.</param>
        /// <param name="lowerBound">The lower bound.</param>
        /// <param name="lowerUnit">The lower bound unit of time.</param>
        /// <param name="lowerBoundType">The indication of how to perform the lower bound check.</param>
        /// <param name="upperBound">The upper bound</param>
        /// <param name="upperUnit">The upper bound unit of time.</param>
        /// <param name="upperBoundType">The indication of how to perform the upper bound check.</param>
        public RelativeDateTimeValidator(int lowerBound, DateTimeUnit lowerUnit, RangeBoundaryType lowerBoundType,
                                         int upperBound, DateTimeUnit upperUnit, RangeBoundaryType upperBoundType,
                                         string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateRelativeDatimeValidator(lowerBound, lowerUnit, lowerBoundType, upperBound, upperUnit, upperBoundType);

            this.lowerBound     = lowerBound;
            this.lowerUnit      = lowerUnit;
            this.lowerBoundType = lowerBoundType;
            this.upperBound     = upperBound;
            this.upperUnit      = upperUnit;
            this.upperBoundType = upperBoundType;

            BuildRangeChecker();    // force validation of parameters
        }
コード例 #13
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="EnumConversionValidatorAttribute"/> </para>
        /// </summary>
        public EnumConversionValidatorAttribute(Type enumType)
        {
            ValidatorArgumentsValidatorHelper.ValidateEnumConversionValidator(enumType);

            this.enumType = enumType;
        }
コード例 #14
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="TypeConversionValidatorAttribute"/>.</para>
        /// </summary>
        /// <param name="targetType">The supplied type used to determine if the string can be converted to it.</param>
        public TypeConversionValidatorAttribute(Type targetType)
        {
            ValidatorArgumentsValidatorHelper.ValidateTypeConversionValidator(targetType);

            this.targetType = targetType;
        }