Explain the types of Model Validation DataAnnotations

 Types of Model Validation DataAnnotations

1. [Required] - Specifies that a value needs to be provided for this property

2. [StringLength] - Allows you to specify at least a maximum amount of characters. We can also add Minumum Length as well. 

[StringLength (50, MinimumLength = 3)]

3. [Range] - specify a minimum and a maximum value for a numeric property (int, float, double etc.)

[Range(1, 100)]

4. [Compare] - allows you to set up a comparison between the property

[Compare ("MailAddressRepeated")]

public string MailAddress { get; set; }

public string MailAddressRepeated { get; set; }


Comments

Popular posts from this blog

What are different steps used in JDBC? Write down a small program showing all steps.

Discuss classification or taxonomy of virtualization at different levels.

Pure Versus Partial EC