Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using Plugin.ValidationRules;
using ValidationRulesTest.Validations;
using ValidationRulesTest.Models;
namespace ValidationRulesTest.ViewModels
public class Example2ViewModel
public Example2ViewModel()
User = new User();
public User User { get; set; }
private void AddValidations()
// Name validations
User.Name.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "A name is required." });
//Lastname validations
User.LastName.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "A lastname is required." });
//Email validations
User.Email.Validations.Add(new IsNotNullOrEmptyRule<string>{ ValidationMessage = "A email is required." });
User.Email.Validations.Add(new EmailRule<string> { ValidationMessage = "Email is not valid." });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment