Esempio n. 1
0
        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(name))
            {
                validationResult.Append($"Name cannot be empty");
            }
            if (string.IsNullOrWhiteSpace(surname))
            {
                validationResult.Append($"Surname cannot be empty");
            }
            if (!(0 < age && age < 100))
            {
                validationResult.Append($"GroupIndex  is out of range (0..100)");
            }

            if (!string.IsNullOrEmpty(name) && !char.IsUpper(name.FirstOrDefault()))
            {
                validationResult.Append($"Name {name} should start from capital letter");
            }
            if (!string.IsNullOrEmpty(surname) && !char.IsUpper(surname.FirstOrDefault()))
            {
                validationResult.Append($"Surname {surname} should start from capital letter");
            }

            return(validationResult);
        }
Esempio n. 2
0
        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(Email))
            {
                validationResult.Append($"Поле Email не может быть пустым!");
            }
            if (string.IsNullOrWhiteSpace(Phone))
            {
                validationResult.Append($"Поле телефон не может быть пустым!");
            }
            if (Phone.Length != 11)
            {
                validationResult.Append($"Телефон должен состоять из 11 символов");
            }
            if (!string.IsNullOrEmpty(Name) && !char.IsUpper(Name.FirstOrDefault()))
            {
                validationResult.Append($"Имя должно начинаться с большой буквы!");
            }

            return(validationResult);
        }