Categories

Data Validation

Data validation is the process of ensuring that a program operates on clean, correct and useful data. Most .NET developers use Data Annotation Validators. 
GrandNode uses Fluent Validation. It's a small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules for your business objects. 

step1

In order to add a Validator to your view model, add folder and file as below

step2

Your Validator class should inherit from BaseNopValidator<T> where T is your View Model class

step3

It is worth to mention you View Model needs to have added this Attribute (otherwise Validator won't work)

step4

The example definition of ShippingPointValidator

step5

ASP.NET will execute the appropriate validator when a view model is posted to a Action Method (of Controller).

back to top