public Validator Matchs(string value, string pattern, string property, ENotifications notifications) { if (!Regex.IsMatch(value ?? string.Empty, pattern ?? string.Empty)) { AddNotification(property, notifications); } return(this); }
public Validator NotNull(object value, string property, ENotifications notification) { if (value == null) { AddNotification(property, notification); } return(this); }
public Validator NotNullOrEmpty(string value, string property, ENotifications notification) { if (string.IsNullOrEmpty(value)) { AddNotification(property, notification); } return(this); }
public Validator MaxLength(string value, int length, string property, ENotifications notification) { if ((value ?? string.Empty).Length > length) { AddNotification(property, notification); } return(this); }
public Validator GreaterThan(double value, double comparer, string property, ENotifications message) { if (value <= comparer) { AddNotification(property, message); } return(this); }
public Validator Equals(double value, double comparer, string property, ENotifications message) { if (value != comparer) { AddNotification(property, message); } return(this); }
public Validator LowerThan(double value, double comparer, string property, ENotifications notification) { if (value >= comparer) { AddNotification(property, notification); } return(this); }
private string Description(ENotifications notification) { DescriptionAttribute[] attributes = (DescriptionAttribute[])notification.GetType().GetField(notification.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes != null && attributes.Length > 0 ? attributes[0].Description : notification.ToString()); }
public void AddNotification(string property, ENotifications message) => AddNotification(property, Description(message));
public Validator Between(double value, double from, double to, string property, ENotifications notification) { if (value < from || value > to) { AddNotification(property, notification); } return(this); }
public Validator GreaterOrEqualsThan(double value, double comparer, string property, ENotifications notification) { if (value < comparer) { AddNotification(property, notification); } return(this); }