/// <summary>
 /// Initializes a new instance of the <see cref="LikertValidator"/> class.
 /// </summary>
 /// <param name="allControls">The list of all controls.</param>
 /// <param name="wrappedValidator">The wrapped validator that does the actual validation.</param>
 /// <param name="controlName">The name of the control validated by the current instance.</param>
 public LikertValidator(ControlList allControls, ControlValueValidator wrappedValidator, string controlName)
     : base(allControls, wrappedValidator, controlName)
 {
 }
        /// <summary>
        /// Creates validators for <paramref name="control"/>.
        /// </summary>
        /// <param name="control">The control to create validators for.</param>
        /// <returns>Validators for <paramref name="control"/>.</returns>
        private ControlValueValidator CreateValidatorForControl(Control control)
        {
            if (control is CalculationControl)
            {
                return null;
            }

            List<Validator> fieldValidators = new List<Validator>();
            ValueControl valueControl = control as ValueControl;
            if (valueControl != null && valueControl.Mandatory)
            {
                fieldValidators.Add(this.CreateValidatorForMandatory(valueControl));
            }

            IControlWithOptions controlWithOptions = control as IControlWithOptions;
            if (controlWithOptions != null)
            {
                fieldValidators.Add(this.CreateValidatorForOptions(controlWithOptions.OptionValues));
            }

            if (valueControl != null)
            {
                fieldValidators.AddRange(valueControl.Validators.Select(this.CreateValidatorForRegex));
            }

            LikertControl likertControl = control as LikertControl;
            if (likertControl != null)
            {
                fieldValidators.Add(this.CreateValidatorForLikertScale(likertControl.Scale));
            }

            RepeaterControl repeaterControl = control as RepeaterControl;
            if (repeaterControl != null)
            {
                fieldValidators.Add(this.CreateValidatorForRepeaterItemCount(repeaterControl));
                fieldValidators.Add(new RepeaterValidator(this.allControls, this.CreateControlListValidator(repeaterControl.Controls), control.Name));
            }

            if (repeaterControl != null && !string.IsNullOrEmpty(repeaterControl.MasterControlName))
            {
                fieldValidators.Add(new LinkedRepeaterValidator(this.allControls, control.Name, repeaterControl.MasterControlName));
            }

            TextControl textControl = control as TextControl;
            if (textControl != null && textControl.MaxLength.HasValue)
            {
                fieldValidators.Add(this.CreateValidatorForMaxLength(textControl));
            }

            DateControl dateControl = control as DateControl;
            if (dateControl != null && (!string.IsNullOrEmpty(dateControl.MinimumDateExpression) || !string.IsNullOrEmpty(dateControl.MaximumDateExpression)))
            {
                fieldValidators.Add(this.CreateValidatorForDateRange(dateControl));
            }

            if (fieldValidators.Count == 0)
            {
                return null;
            }

            IControlWithLabel controlWithLabel = control as IControlWithLabel;
            string fieldLabel = controlWithLabel != null ? controlWithLabel.Label : control.Name;
            fieldValidators.ForEach(v => v.Tag = fieldLabel);

            ControlValueValidator controlValueValidator = new ControlValueValidator(this.allControls, new EntLib.AndCompositeValidator(fieldValidators.ToArray()), control.Name);
            if (likertControl != null)
            {
                fieldValidators.Add(this.CreateValidatorForLikertScale(likertControl.Scale));
                return new LikertValidator(this.allControls, controlValueValidator, control.Name);
            }

            return controlValueValidator;
        }