예제 #1
0
        public IEnumerable <ValidationError> Visit(AssetsFieldProperties properties)
        {
            if (IsMaxGreaterThanMin(properties.MaxItems, properties.MinItems))
            {
                yield return(new ValidationError(Not.GreaterEqualsThan(nameof(properties.MaxItems), nameof(properties.MinItems)),
                                                 nameof(properties.MinItems),
                                                 nameof(properties.MaxItems)));
            }

            if (IsMaxGreaterThanMin(properties.MaxHeight, properties.MinHeight))
            {
                yield return(new ValidationError(Not.GreaterEqualsThan(nameof(properties.MaxHeight), nameof(properties.MinHeight)),
                                                 nameof(properties.MaxHeight),
                                                 nameof(properties.MinHeight)));
            }

            if (IsMaxGreaterThanMin(properties.MaxWidth, properties.MinWidth))
            {
                yield return(new ValidationError(Not.GreaterEqualsThan(nameof(properties.MaxWidth), nameof(properties.MinWidth)),
                                                 nameof(properties.MaxWidth),
                                                 nameof(properties.MinWidth)));
            }

            if (IsMaxGreaterThanMin(properties.MaxSize, properties.MinSize))
            {
                yield return(new ValidationError(Not.GreaterThan(nameof(properties.MaxSize), nameof(properties.MinSize)),
                                                 nameof(properties.MaxSize),
                                                 nameof(properties.MinSize)));
            }

            if (properties.AspectWidth.HasValue != properties.AspectHeight.HasValue)
            {
                yield return(new ValidationError(Not.BothDefined(nameof(properties.AspectWidth), nameof(properties.AspectHeight)),
                                                 nameof(properties.AspectWidth),
                                                 nameof(properties.AspectHeight)));
            }
        }