Skip to content

Instantly share code, notes, and snippets.

@luismts
Created October 15, 2018 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luismts/88968558bf7cc161436734867e3d1659 to your computer and use it in GitHub Desktop.
Save luismts/88968558bf7cc161436734867e3d1659 to your computer and use it in GitHub Desktop.
using Plugin.ValidationRules;
using ValidationRulesTest.Validations;
using ValidationRulesTest.Models;
namespace ValidationRulesTest.ViewModels
{
public class Example2ViewModel
{
public Example2ViewModel()
{
User = new User();
AddValidations();
}
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