wpf-9770-controls-and-libraries-data-grid-data-editing-and-validation-input-validation-attribute-based-validation.md
The GridControl supports DataAnnotations attributes that specify data validation rules. You should reference the System.ComponentModel.DataAnnotations assembly to use data annotation attributes.
View Example: How to Implement Attributes-Based Validation
| Validation Attribute | Description |
|---|---|
| CustomValidationAttribute | Specifies a custom validation method. |
| DataTypeAttribute | Specifies a particular data type, such as an e-mail address or a phone number. |
| EnumDataTypeAttribute | Ensures that the value exists in an enumeration. |
| RangeAttribute | Designates minimum and maximum constraints. |
| RegularExpressionAttribute | Uses a regular expression to determine valid values. |
| RequiredAttribute | Specifies that a value must be provided. |
| StringLengthAttribute | Designates maximum and minimum number of characters. |
The GridControl displays error icons ( ) within cells with invalid values, and provides error descriptions displayed as tooltips. In this case, you cannot focus another cell until the cell’s value is corrected:
The following validation options allow you to override default behavior:
|
Validation Attribute
|
Description
| | --- | --- | |
ColumnBase.ShowValidationAttributeErrors
DataViewBase.ShowValidationAttributeErrors
|
If set to false , hides validation errors specified via DataAnnotations attributes.
| |
DataViewBase.AllowCommitOnValidationAttributeError
|
If set to true , posts the invalid value to a data source and allows the cell focus to be moved to another cell.
|
The attributes-based validation does not work when you use the ColumnBase.Binding property.