コード例 #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 });
        }