Esempio n. 1
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
            var    error        = FormatErrorMessage(metadata.DisplayName);
            string errorMessage = StringBuilderMessageStringLength.Message(error, MinimumLength, MaximumLength);

            var rule = new ModelClientValidationStringLengthRule($"{_errorFieldName} - {errorMessage}", MinimumLength, MaximumLength);

            yield return(rule);
        }
Esempio n. 2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            //Needed if javascript disabled
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
            var    error        = FormatErrorMessage(validationContext.DisplayName);
            string errorMessage = StringBuilderMessageStringLength.Message(error, MinimumLength, MaximumLength);

            if (IsValid(value))
            {
                return(ValidationResult.Success);
            }

            return(new ValidationResult(_errorFieldName + " " + errorMessage + " " + "Javascript disabled"));
        }