diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoCompareAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoCompareAttribute.cs index bdac64d..ba8b54a 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoCompareAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoCompareAttribute.cs @@ -16,11 +16,12 @@ public sealed class UmbracoCompareAttribute : System.ComponentModel.DataAnnotati public UmbracoCompareAttribute(string otherProperty) : base(otherProperty) { - ErrorMessageString = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessageString = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + if (metadata.ContainerType != null) { if (OtherPropertyDisplayName == null) diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoMaxLengthAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoMaxLengthAttribute.cs index 126dcd4..05a70c1 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoMaxLengthAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoMaxLengthAttribute.cs @@ -15,11 +15,12 @@ public sealed class UmbracoMaxLengthAttribute : MaxLengthAttribute, IClientValid public UmbracoMaxLengthAttribute(int length) : base(length) { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + yield return new ModelClientValidationMaxLengthRule(FormatErrorMessage(metadata.GetDisplayName()), Length); } diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoMinLengthAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoMinLengthAttribute.cs index 2ec6de0..6d1d1e0 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoMinLengthAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoMinLengthAttribute.cs @@ -15,11 +15,12 @@ public sealed class UmbracoMinLengthAttribute : MinLengthAttribute, IClientValid public UmbracoMinLengthAttribute(int length) : base(length) { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + yield return new ModelClientValidationMinLengthRule(FormatErrorMessage(metadata.GetDisplayName()), Length); } diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoRangeAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoRangeAttribute.cs index 644067d..1672c30 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoRangeAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoRangeAttribute.cs @@ -12,11 +12,12 @@ public sealed class UmbracoRangeAttribute : RangeAttribute, IClientValidatable, public UmbracoRangeAttribute(int minimum, int maximum) : base(minimum, maximum) { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + yield return new ModelClientValidationRangeRule(FormatErrorMessage(metadata.GetDisplayName()), Minimum, Maximum); } diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoRegularExpressionAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoRegularExpressionAttribute.cs index b2a35b5..a6dc43c 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoRegularExpressionAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoRegularExpressionAttribute.cs @@ -15,11 +15,12 @@ public sealed class UmbracoRegularExpressionAttribute : RegularExpressionAttribu public UmbracoRegularExpressionAttribute(string pattern) : base(pattern) { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + yield return new ModelClientValidationRegexRule(FormatErrorMessage(metadata.GetDisplayName()), Pattern); } } diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoRequiredAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoRequiredAttribute.cs index b03d807..6e26714 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoRequiredAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoRequiredAttribute.cs @@ -15,11 +15,11 @@ public sealed class UmbracoRequiredAttribute : RequiredAttribute, IClientValidat public UmbracoRequiredAttribute() : base() { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); yield return new ModelClientValidationRequiredRule(FormatErrorMessage(metadata.GetDisplayName())); } } diff --git a/src/Our.Umbraco.DataAnnotations/UmbracoStringLengthAttribute.cs b/src/Our.Umbraco.DataAnnotations/UmbracoStringLengthAttribute.cs index 304f2dc..9fb26a4 100644 --- a/src/Our.Umbraco.DataAnnotations/UmbracoStringLengthAttribute.cs +++ b/src/Our.Umbraco.DataAnnotations/UmbracoStringLengthAttribute.cs @@ -15,11 +15,12 @@ public sealed class UmbracoStringLengthAttribute : StringLengthAttribute, IClien public UmbracoStringLengthAttribute(int maximumLength) : base(maximumLength) { - ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); } public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { + ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey); + yield return new ModelClientValidationStringLengthRule(FormatErrorMessage(metadata.GetDisplayName()), MinimumLength, MaximumLength); }