Exemple #1
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
            var error = FormatErrorMessage(metadata.DisplayName);
            var rule  = new ModelClientValidationRequiredRule(error);

            yield return(rule);
        }
Exemple #2
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);
        }
Exemple #3
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"));
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            //Needed if javascript disabled
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
            var removeRegex = ExtractStringBetweenTags.ExtractString(Pattern);

            var error = FormatErrorMessage(validationContext.DisplayName);

            string errorMessage = StringBuilderMessage.Message(error, removeRegex);

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

            return(new ValidationResult(_errorFieldName + " " + errorMessage + " " + "Javascript disabled"));
        }
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);

            var removeRegex = ExtractStringBetweenTags.ExtractString(Pattern);

            var    error        = FormatErrorMessage(metadata.DisplayName);
            string errorMessage = StringBuilderMessage.Message(error, removeRegex);

            var rule = new ModelClientValidationRule
            {
                ErrorMessage   = $"{_errorFieldName} - {errorMessage}",
                ValidationType = "regex"
            };

            rule.ValidationParameters.Add("pattern", Pattern);

            yield return(rule);
        }
Exemple #6
0
 public UmbracoGetPropertyValueRequired(string errorMessageKey)
 {
     _errorMessageKey = errorMessageKey;
     ErrorMessage     = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
 }