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. 


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


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


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


The example definition of ShippingPointValidator


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

back to top