/// <summary>
        /// Creates validation rule.
        /// </summary>
        /// <param name="type">Type of numeric question, integer or decimal.</param>
        /// <param name="min">Min input value.</param>
        /// <param name="max">Max input value.</param>
        public RangeValidationRule(NumericQuestion.Types type, double?min, double?max)
        {
            switch (type)
            {
            case NumericQuestion.Types.DecimalType:
                RegexRule = new RegexValidationRule(_regexDecimalPattern);
                break;

            case NumericQuestion.Types.IntegerType:
                RegexRule = new RegexValidationRule(_regexIntegerPattern);
                break;
            }
            if (max != null)
            {
                _max         = max;
                _hasMaxRange = true;
            }
            if (min != null)
            {
                _min         = min;
                _hasMinRange = true;
            }

            Message           = EmptyErrorMessage = Languages.AppResources.validationRules_LengthEmptyMessage;
            MaxReachedMessage = Languages.AppResources.validationRules_MaxReachedMessage;
            MinReachedMessage = Languages.AppResources.validationRules_MinReachedMessage;
        }
Ejemplo n.º 2
0
        private Question CreateNumericQuestion(XElement questionIterator, NumericQuestion.Types type, Category parent)
        {
            NumericQuestion numericQuestion = new NumericQuestion(parent, type);

            if (questionIterator.Attribute("min").Value != "")
            {
                numericQuestion.MinValue = Convert.ToDouble(questionIterator.Attribute("min").Value);
            }
            if (questionIterator.Attribute("max").Value != "")
            {
                numericQuestion.MaxValue = Convert.ToDouble(questionIterator.Attribute("max").Value);
            }
            numericQuestion.Length = Convert.ToInt32(questionIterator.Element("length").Value);

            return(numericQuestion);
        }