コード例 #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            if (Actors != null && Actors.Any())
            {
                bool duplicates = Actors.GroupBy(a => a).Any(a => a.Count() > 1);
                if (duplicates)
                {
                    errors.Add(new ValidationResult("Duplicate actors", new[] { "Actors" }));
                }
            }

            return(errors);
        }