Skip to content

Commit

Permalink
Merge pull request #9 from GianniDPC/master
Browse files Browse the repository at this point in the history
Fix custom umbraco dictionary keys not working once again
  • Loading branch information
rasmuseeg authored Oct 14, 2019
2 parents 1711cbd + 8daf0e2 commit 9408e8c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Our.Umbraco.DataAnnotations/UmbracoCompareAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public sealed class UmbracoCompareAttribute : System.ComponentModel.DataAnnotati
public UmbracoCompareAttribute(string otherProperty)
: base(otherProperty)
{
ErrorMessageString = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessageString = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

if (metadata.ContainerType != null)
{
if (OtherPropertyDisplayName == null)
Expand Down
3 changes: 2 additions & 1 deletion src/Our.Umbraco.DataAnnotations/UmbracoMaxLengthAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed class UmbracoMaxLengthAttribute : MaxLengthAttribute, IClientValid
public UmbracoMaxLengthAttribute(int length)
: base(length)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

yield return
new ModelClientValidationMaxLengthRule(FormatErrorMessage(metadata.GetDisplayName()), Length);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Our.Umbraco.DataAnnotations/UmbracoMinLengthAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed class UmbracoMinLengthAttribute : MinLengthAttribute, IClientValid
public UmbracoMinLengthAttribute(int length)
: base(length)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

yield return
new ModelClientValidationMinLengthRule(FormatErrorMessage(metadata.GetDisplayName()), Length);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Our.Umbraco.DataAnnotations/UmbracoRangeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

yield return
new ModelClientValidationRangeRule(FormatErrorMessage(metadata.GetDisplayName()), Minimum, Maximum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed class UmbracoRegularExpressionAttribute : RegularExpressionAttribu
public UmbracoRegularExpressionAttribute(string pattern)
: base(pattern)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

yield return new ModelClientValidationRegexRule(FormatErrorMessage(metadata.GetDisplayName()), Pattern);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public sealed class UmbracoRequiredAttribute : RequiredAttribute, IClientValidat
public UmbracoRequiredAttribute()
: base()
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
yield return new ModelClientValidationRequiredRule(FormatErrorMessage(metadata.GetDisplayName()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed class UmbracoStringLengthAttribute : StringLengthAttribute, IClien
public UmbracoStringLengthAttribute(int maximumLength)
: base(maximumLength)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);
}

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
ErrorMessage = UmbracoDictionary.GetDictionaryValue(DictionaryKey);

yield return
new ModelClientValidationStringLengthRule(FormatErrorMessage(metadata.GetDisplayName()), MinimumLength, MaximumLength);
}
Expand Down

0 comments on commit 9408e8c

Please sign in to comment.