Created
October 15, 2018 04:48
-
-
Save luismts/88968558bf7cc161436734867e3d1659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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