Completed
Last Updated: 21 Aug 2020 12:32 by ADMIN
Release R3 2020 (LIB 2020.2.826)

RadValidationRule allows you to define a rule for a certain control by specifying the PropertyName that has to be validated. However, RadTextBox doesn't offer a property that specifies how many symbols are entered in the editor. This can be checked by the RadTextBox.Text.Length property.  It would be nice to have support for defining nested properties in the validation rules: RadValidationRule.PropertyName ="Text.Length".

Workaround: 

The possible solution that I can suggest is to add a RadValidationRule for empty Text and in addition to this handle the ControlValidation event which occurs before a RadEditorControl is being validated. The RadValidationEventArgs gives very useful information about the tool tip error indication, validation rule, etc. The IsValid argument allows you to override the default result indicating whether the validation fails and change the error message accordingly: 

        public RadForm1()
        {
            InitializeComponent();

            RadValidationRule radValidationRule1 = new RadValidationRule();
            radValidationRule1.AutoToolTip = true;
            radValidationRule1.AddControl(this.radTextBox1);
            radValidationRule1.Operator = Telerik.WinControls.Data.FilterOperator.IsNotLike;
            radValidationRule1.PropertyName = "Text";
            radValidationRule1.ToolTipText = "Text is empty!";
            radValidationRule1.Value = "";

            radValidationProvider1.ValidationRules.Add(radValidationRule1);

            this.radValidationProvider1.ControlValidation += radValidationProvider1_ControlValidation;
        }

        private void radValidationProvider1_ControlValidation(object sender, RadValidationEventArgs e)
        {
            if (e.Control == this.radTextBox1 && this.radTextBox1.Text != string.Empty &&
                this.radTextBox1.TextBoxElement.TextBoxItem.TextLength < 20)
            {
                e.ErrorText = "Text is less than 20 characters !";
                e.IsValid = false;
            }
        }

Completed
Last Updated: 09 Jun 2020 12:59 by ADMIN
Release R2 2020 SP1

This breaks the Expression:

This is how it should be properly defined:

It would be nice to have the possibility for defining the PropertyName in a case insensitive manner.

Completed
Last Updated: 15 Dec 2020 13:32 by ADMIN
Release R1 2021
I have user control which is used to edit a certain entity on my system - say a person. It has several text boxes to exit various properties and they are all linked to a ValidationProvider with rules. That UC is loaded on a form. The user of my software can choose which person to edit from a list and he/she can choose to edit multiple person entities in a row. So here is where I have a problem:

User clicks on Person1 and the UC with ValidationProvider is shown. Say the user clears a textbox which results in validation error - the textbox will be marked with red. Now if the user switches to edit another entity (Person2), the program does not create a new UC but instead it reuses the existing UC and sets the values of the textboxes to the values of Person2. But because the previous edit has a validation error but red textbox will still remain red. This is where the problem is. The only way to remove the error state is to trigger validation again but that cannot happen until the user start typing which is not the desired behavior. 

It would be really helpful to have a method on the ValidationProvider to clear the invalid states of all linked controls - resetting them to the default state. That when whenever the user switches to edit Person2, I can reset the states of the controls so that the error from the previous edit disappears.

Currently I have worked around the problem by creating a new instance of the UC for each edit but that might not be ideal if you have a somewhat large edit form and you need to refresh it very quickly.