예제 #1
0
        public ContainsCharactersValidatorAttribute(string characterSet, ContainsCharacters containsCharacters)
        {
            ValidatorArgumentsValidatorHelper.ValidateContainsCharacterValidator(characterSet);

            _characterSet       = characterSet;
            _containsCharacters = containsCharacters;
        }
        /// <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);

            _targetType = targetType;
        }
        public ContainsCharactersValidator(string characterSet, ContainsCharacters containsCharacters, string messageTemplate, bool negated)
            : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateContainsCharacterValidator(characterSet);

            _characterSet       = characterSet;
            _containsCharacters = containsCharacters;
        }
예제 #5
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);

            _rangeChecker = new RangeChecker <T>(lowerBound, lowerBoundType, upperBound, upperBoundType);
        }
예제 #6
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);

            _pattern             = pattern;
            _options             = options;
            _patternResourceName = patternResourceName;
            _patternResourceType = patternResourceType;
        }
예제 #7
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);

            _pattern             = pattern;
            _options             = options;
            _patternResourceName = patternResourceName;
            _patternResourceType = patternResourceType;
        }
예제 #8
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);

            _lowerBound     = lowerBound;
            _lowerUnit      = lowerUnit;
            _lowerBoundType = lowerBoundType;
            _upperBound     = upperBound;
            _upperUnit      = upperUnit;
            _upperBoundType = upperBoundType;
        }
예제 #9
0
        private RangeValidatorAttribute(
            Type boundType,
            object lowerBound, IComparable effectiveLowerBound, RangeBoundaryType lowerBoundType,
            object upperBound, IComparable effectiveUpperBound, RangeBoundaryType upperBoundType)
        {
            ValidatorArgumentsValidatorHelper.ValidateRangeValidator(effectiveLowerBound, lowerBoundType, effectiveUpperBound, upperBoundType);

            _boundType           = boundType;
            _lowerBound          = lowerBound;
            _effectiveLowerBound = effectiveLowerBound;
            _lowerBoundType      = lowerBoundType;
            _upperBound          = upperBound;
            _effectiveUpperBound = effectiveUpperBound;
            _upperBoundType      = upperBoundType;
        }
예제 #10
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);

            _lowerBound     = lowerBound;
            _lowerUnit      = lowerUnit;
            _lowerBoundType = lowerBoundType;
            _upperBound     = upperBound;
            _upperUnit      = upperUnit;
            _upperBoundType = upperBoundType;

            BuildRangeChecker();    // force validation of parameters
        }
예제 #11
0
        /// <summary>
        /// <para>Initializes a new instance of the <see cref="EnumConversionValidatorAttribute"/> </para>
        /// </summary>
        /// <param name="enumType">The type of enum that should be validated</param>
        public EnumConversionValidatorAttribute(Type enumType)
        {
            ValidatorArgumentsValidatorHelper.ValidateEnumConversionValidator(enumType);

            _enumType = enumType;
        }
예제 #12
0
        public DomainValidatorAttribute(params object[] domain) : base()
        {
            ValidatorArgumentsValidatorHelper.ValidateDomainValidator(domain);

            _domain = domain;
        }
        /// <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);

            _targetType = targetType;
        }
예제 #14
0
        public DomainValidator(IEnumerable <T> domain, string messageTemplate, bool negated) : base(messageTemplate, null, negated)
        {
            ValidatorArgumentsValidatorHelper.ValidateDomainValidator(domain);

            _domain = domain;
        }