コード例 #1
0
        public override void Validate(object value)
        {
            ValidatorUtils.HelperParamValidation(value, typeof(string));

            if (value == null)
            {
                return;
            }

            Match match = _regex.Match((string)value);

            if (!match.Success)
            {
                throw new ArgumentException(SR.Format(SR.Regex_validator_error, _expression));
            }
        }
コード例 #2
0
        public override void Validate(object value)
        {
            if (value == null)
            {
                return;
            }

            // Make a check here since value.GetType() returns RuntimeType rather then Type
            if (!(value is Type))
            {
                ValidatorUtils.HelperParamValidation(value, typeof(Type));
            }

            if (!_base.IsAssignableFrom((Type)value))
            {
                throw new ArgumentException(SR.GetString(SR.Subclass_validator_error, ((Type)value).FullName, _base.FullName));
            }
        }
コード例 #3
0
        public override void Validate(object value)
        {
            ValidatorUtils.HelperParamValidation(value, typeof(string));
            string str = value as string;
            int    num = (str == null) ? 0 : str.Length;

            if (num < this._minLength)
            {
                throw new ArgumentException(System.Configuration.SR.GetString("Validator_string_min_length", new object[] { this._minLength }));
            }
            if (num > this._maxLength)
            {
                throw new ArgumentException(System.Configuration.SR.GetString("Validator_string_max_length", new object[] { this._maxLength }));
            }
            if (((num > 0) && (this._invalidChars != null)) && (this._invalidChars.Length > 0))
            {
                char[] destination = new char[this._invalidChars.Length];
                this._invalidChars.CopyTo(0, destination, 0, this._invalidChars.Length);
                if (str.IndexOfAny(destination) != -1)
                {
                    throw new ArgumentException(System.Configuration.SR.GetString("Validator_string_invalid_chars", new object[] { this._invalidChars }));
                }
            }
        }
コード例 #4
0
 public override void Validate(object value)
 {
     ValidatorUtils.HelperParamValidation(value, typeof(long));
     ValidatorUtils.ValidateScalar <long>((long)value, this._minValue, this._maxValue, this._resolution, this._flags == ValidationFlags.ExclusiveRange);
 }