Beispiel #1
0
 protected static bool Compare(string left,
                               string right,
                               ValidationCompareOperator op,
                               ValidationDataType type)
 {
     return(BaseCompareValidator.Compare(left, false, right, false, op, type));
 }
        protected override bool EvaluateIsValid()
        {
            string control_value;

            control_value = GetControlValidationValue(this.ControlToValidate);
            if (control_value == null)
            {
                return(true);
            }
            control_value = control_value.Trim();
            if (control_value.Length == 0)
            {
                return(true);
            }

            string compare;
            /* ControlToCompare takes precendence, if it's set. */
            string controlToCompare = ControlToCompare;

            compare = (!String.IsNullOrEmpty(controlToCompare) ? GetControlValidationValue(controlToCompare) : ValueToCompare);

            return(BaseCompareValidator.Compare(GetControlValidationValue(ControlToValidate), false,
                                                compare, this.CultureInvariantValues,
                                                Operator, this.Type));
        }
        protected override bool EvaluateIsValid()
        {
            string controlValidationValue = base.GetControlValidationValue(base.ControlToValidate);

            if (controlValidationValue.Trim().Length == 0)
            {
                return(true);
            }
            bool flag = (base.Type == ValidationDataType.Date) && !this.DetermineRenderUplevel();

            if (flag && !base.IsInStandardDateFormat(controlValidationValue))
            {
                controlValidationValue = base.ConvertToShortDateString(controlValidationValue);
            }
            bool   cultureInvariantRightText = false;
            string date = string.Empty;

            if (this.ControlToCompare.Length > 0)
            {
                date = base.GetControlValidationValue(this.ControlToCompare);
                if (flag && !base.IsInStandardDateFormat(date))
                {
                    date = base.ConvertToShortDateString(date);
                }
            }
            else
            {
                date = this.ValueToCompare;
                cultureInvariantRightText = base.CultureInvariantValues;
            }
            return(BaseCompareValidator.Compare(controlValidationValue, false, date, cultureInvariantRightText, this.Operator, base.Type));
        }
        protected override bool EvaluateIsValid()
        {
            string controlValidationValue = base.GetControlValidationValue(base.ControlToValidate);

            if (controlValidationValue.Trim().Length == 0)
            {
                return(true);
            }
            if (((base.Type == ValidationDataType.Date) && !this.DetermineRenderUplevel()) && !base.IsInStandardDateFormat(controlValidationValue))
            {
                controlValidationValue = base.ConvertToShortDateString(controlValidationValue);
            }
            return(BaseCompareValidator.Compare(controlValidationValue, false, this.MinimumValue, base.CultureInvariantValues, ValidationCompareOperator.GreaterThanEqual, base.Type) && BaseCompareValidator.Compare(controlValidationValue, false, this.MaximumValue, base.CultureInvariantValues, ValidationCompareOperator.LessThanEqual, base.Type));
        }
        private void ValidateValues()
        {
            string maximumValue = this.MaximumValue;

            if (!BaseCompareValidator.CanConvert(maximumValue, base.Type, base.CultureInvariantValues))
            {
                throw new HttpException(System.Web.SR.GetString("Validator_value_bad_type", new string[] { maximumValue, "MaximumValue", this.ID, PropertyConverter.EnumToString(typeof(ValidationDataType), base.Type) }));
            }
            string minimumValue = this.MinimumValue;

            if (!BaseCompareValidator.CanConvert(minimumValue, base.Type, base.CultureInvariantValues))
            {
                throw new HttpException(System.Web.SR.GetString("Validator_value_bad_type", new string[] { minimumValue, "MinimumValue", this.ID, PropertyConverter.EnumToString(typeof(ValidationDataType), base.Type) }));
            }
            if (BaseCompareValidator.Compare(minimumValue, base.CultureInvariantValues, maximumValue, base.CultureInvariantValues, ValidationCompareOperator.GreaterThan, base.Type))
            {
                throw new HttpException(System.Web.SR.GetString("Validator_range_overalap", new string[] { maximumValue, minimumValue, this.ID }));
            }
        }