Skip to content

geeksarray/how-to-validate-mvc-model-using-dataannotation-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

How to validate mvc model using dataannotation attributes

This tutorial helps you to understand how you can use DataAnnotation attributes for validation of model data.

DataAnnotation namespace All DataAnnotation attributes are included in System.ComponentModel.DataAnnotations namespace. Various DataAnnotation attributes give you a simple way to perform validation on model data. These attributes are helpful for common validation patterns like Required, Range, StringLength, etc. It can perform validation on both the client and server side.

Files

  1. Customer Model - with Data Annotation attributes applied on customer properties.

  2. Home Controller - having Customer models used with Data Annotation validation.

Below image shows validation erros triggered by Data Annotations

Data Annotations Validations

For more details visit - https://geeksarray.com/blog/how-to-validate-mvc-model-using-dataannotation-attributes

About

This tutorial helps you to understand how you can use DataAnnotation attributes for validation of model data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published