コード例 #1
0
ファイル: Book.cs プロジェクト: eladmotola/Library
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!General.Validator.IsOnlyLetters(Author.Replace(" ", "")))
            {
                yield return
                    (new ValidationResult(errorMessage: "Author contains only letters",
                                          memberNames: new[] { "Author" }));
            }

            if (ReleaseDate.Date > DateTime.Now.Date)
            {
                yield return
                    (new ValidationResult(errorMessage: "Date can not be greater than today's date",
                                          memberNames: new[] { "ReleaseDate" }));
            }
        }