Validation
One of the most important parts of the application is the correct implementation of validations in our business logic. These can be simple details, such as the fact that the client must provide their name and e-mail address to sign up, or that before selling a book, it must be in stock.
In RIA Services, validations can be defined on two levels:
In entities, via DataAnnotations.
In our Domain Service, server or asynchronous validations via Invoke.
DataAnnotations
The space named System.ComponentModel.DataAnnotations
implements a series of attributes allowing us to add validation rules to the properties of our entities. The following table shows the most outstanding ones:
Validation Attribute |
Description |
---|---|
DataTypeAttribute |
Specifies a particular type of data such as date or an e-mail |
EnumDataTypeAttribute |
Ensures that the value exists in an enumeration |
RangeAttribute |
Designates minimum and maximum constraints |
RegularExpressionAttribute |
Uses a regular expression to determine... |