---
title: "What is Data Annotation Validator Attribute in asp.net MVC?"  
description: "What is Data Annotation Validator Attribute in asp.net MVC?"  
author: "Kalin"  
published: 2022-03-10  
updated: 2022-03-10  
canonical: https://www.mindstick.com/forum/156905/what-is-data-annotation-validator-attribute-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["asp.net", "asp.net mvc"]  
reading_time: 2 minutes  

---

# What is Data Annotation Validator Attribute in asp.net MVC?

What is [Data Annotation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) [Validator](https://www.mindstick.com/interview/598/give-the-details-of-xml-files-used-in-validator-framework) [Attribute in asp.net](https://www.mindstick.com/forum/156059/what-is-outputcache-attribute-in-asp-dot-net-mvc) [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc)?

## Replies

### Reply by Steilla Mitchel

**[Data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) Annotation in MVC:**

There are mazor role of Data Annotation in [asp.net mvc](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc). It is used to validate the properties when designing the model page. This validation is used in both side, client side as well as server side. There are some Data Annotation used in mvc is given below,

## Required :

It is used to specify a property as required.

```
exp. [Required(ErrorMessage='Full Name is Required')]
```

## RegularExpression

It is used to specifies the regular expression to validate the value of the property.

```
exp. - [RegularExpression('[a-z]', ErrorMessage = 'Invalid input characters')]
```

## Range :

It specifies the Range of values which provide this property

```
exp. - [Range(100,1000,ErrorMessage='Enter value between 100 to 1k')]
```

## StringLength :

Specifies the Min length & Max length for a given string property.

```
exp.- [StringLength(50, MinimumLength = 4, ErrorMessage = 'Enter value between 4 and 50 characters ')]
```

## MaxLength :

Specifies the Max length for the entered property value.

```
exp.- [MaxLength(50,ErrorMessage='Enter value less than 50 characters')]
```

## MinLength :

It is used to check for minimum length of property value.

```
exp.- [MinLength(4, ErrorMessage = 'Name is too small, enter more than 4 characters')].
```


---

Original Source: https://www.mindstick.com/forum/156905/what-is-data-annotation-validator-attribute-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
