data annotations

Attributes from System.ComponentModel.DataAnnotations, such as [Required] and [Range(1, 200)], that declare simple validation rules on properties.

In more detail

The same attributes validate request models in controllers and options classes at startup. Rules that involve two properties need code instead.

Example

[Range(1, 200)] public int MaxPageSize { get; set; } = 100;

Related terms

Taught in

References