Validating Data Through Data Annotations
Aside from the property level validation, RadDataForm supports validation through data annotations. Validation is performed on any occasion when changes are committed - navigation, insertion of new items or when AutoCommit is set to True, for example. This feature is available for both auto-generated and customized fields and all of the System.ComponentModel.DataAnnotations validation attributes are supported.
In order to enable this kind of validation you first need to include the System.ComponentModel.DataAnnotations namespace:
Example 1: Including System.ComponentModel.DataAnnotations
using System.ComponentModel.DataAnnotations;Now, let's define a simple Employee class with validation attributes.
Example 2: Creating an Employee class with validation attributes
public class Employee
{
[Required]
public string FirstName { get; set; }
[Required(ErrorMessage = "LastName is required")]
public string LastName { get; set; }
[Range(21, 70)]
public int Age { get; set; }
[RegularExpression("[a-z]#[0-9]*")]
public string EmployeeID { get; set; }
}Figure 1 shows RadDataForm's state after validation has been performed.
Figure 1: RadDataForm after validation has been performed

As seen in the above figure, item level validation errors are not respected by the separate editors' validation features (i.e. no validation tooltip is shown for the TextBox). Such behavior is expected, as respective bindings never get notified about these errors.
In order to notify the UI that validation has failed, you will need to throw a ValidationException. Example 3 shows how to do so through the static ValidateProperty method of the Validator class.
Example 3: Set validation through data DataAnnotations
private string firstName;
[Required]
public string FirstName
{
get { return this.firstName; }
set
{
if (value != this.firstName)
{
ValidationContext validationContext = new ValidationContext(this, null, null);
validationContext.MemberName = "FirstName";
Validator.ValidateProperty(value, validationContext);
this.firstName = value;
this.OnPropertyChanged("FirstName");
}
}
}Please, have in mind that those errors are removed from the validation summary on the next committing operation, unlike the property level ones, which are removed on property change.