Пример #1
0
        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);
        }
Пример #2
0
        public Validator NotNull(object value, string property, ENotifications notification)
        {
            if (value == null)
            {
                AddNotification(property, notification);
            }

            return(this);
        }
Пример #3
0
        public Validator NotNullOrEmpty(string value, string property, ENotifications notification)
        {
            if (string.IsNullOrEmpty(value))
            {
                AddNotification(property, notification);
            }

            return(this);
        }
Пример #4
0
        public Validator MaxLength(string value, int length, string property, ENotifications notification)
        {
            if ((value ?? string.Empty).Length > length)
            {
                AddNotification(property, notification);
            }

            return(this);
        }
Пример #5
0
        public Validator GreaterThan(double value, double comparer, string property, ENotifications message)
        {
            if (value <= comparer)
            {
                AddNotification(property, message);
            }

            return(this);
        }
Пример #6
0
        public Validator Equals(double value, double comparer, string property, ENotifications message)
        {
            if (value != comparer)
            {
                AddNotification(property, message);
            }

            return(this);
        }
Пример #7
0
        public Validator LowerThan(double value, double comparer, string property, ENotifications notification)
        {
            if (value >= comparer)
            {
                AddNotification(property, notification);
            }

            return(this);
        }
Пример #8
0
        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());
        }
Пример #9
0
 public void AddNotification(string property, ENotifications message) => AddNotification(property, Description(message));
Пример #10
0
        public Validator Between(double value, double from, double to, string property, ENotifications notification)
        {
            if (value < from || value > to)
            {
                AddNotification(property, notification);
            }

            return(this);
        }
Пример #11
0
        public Validator GreaterOrEqualsThan(double value, double comparer, string property, ENotifications notification)
        {
            if (value < comparer)
            {
                AddNotification(property, notification);
            }

            return(this);
        }