Пример #1
0
        public override IEnumerable <ModelClientValidationRule> GetClientValidationRules(
            [NotNull] ClientModelValidationContext context)
        {
            var errorMessage = GetErrorMessage(context.ModelMetadata);
            var rule         = new ModelClientValidationStringLengthRule(errorMessage,
                                                                         Attribute.MinimumLength,
                                                                         Attribute.MaximumLength);

            return(new[] { rule });
        }
Пример #2
0
        public override IEnumerable <ModelClientValidationRule> GetClientValidationRules(
            ClientModelValidationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var errorMessage = GetErrorMessage(context);
            var rule         = new ModelClientValidationStringLengthRule(errorMessage,
                                                                         Attribute.MinimumLength,
                                                                         Attribute.MaximumLength);

            return(new[] { rule });
        }