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);
        }