예제 #1
0
파일: model.cs 프로젝트: Skomarovski/lab
        }                                 // Цена

        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(name))
            {
                validationResult.Append($"Book title cannot be empty");
            }
            if (string.IsNullOrWhiteSpace(author))
            {
                validationResult.Append($"Author name cannot be empty");
            }
            if (string.IsNullOrWhiteSpace(publ))
            {
                validationResult.Append($"Publisher cannot be empty");
            }
            if (!(date > 0))
            {
                validationResult.Append($"Date must be higher than 0");
            }
            if (!(price > 0))
            {
                validationResult.Append($"Price must be higher than 0");
            }

            return(validationResult);
        }
예제 #2
0
파일: myData.cs 프로젝트: JulsVa/lr4
        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 < GroupIndex && GroupIndex < 100))
            {
                validationResult.Append($"GroupIndex {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);
        }