System.ComponentModel.Annotations provides attributes and classes for adding metadata to your data models. Common uses include:
1. Validation: Attributes like [Required], [StringLength], and [Range] for data validation.
2. Display: Attributes like [Display] to specify display names and formats.
3. Metadata: Attributes like [MetadataType] for associating metadata with types.
using System.ComponentModel.DataAnnotations;
public class Person
{
[Required] // Marks this property as required
[StringLength(100)] // Sets the maximum length
public string Name { get; set; }
[Range(0, 120)] // Specifies acceptable range for the age
public int Age { get; set; }
}
System.ComponentModel.Annotations provides attributes and classes for adding metadata to your data models. Common uses include:
https://swagger.io/docs/specification/data-models/data-types/ -> Minimum and Maximum