Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Issue: Equal does not use the Display Attribute [7125]

$
0
0
```c#
[Display(Name = "NewPassword", ResourceType = typeof(Labels))]
[DataType(DataType.Password)]
public string NewPassword { get; set; }

[Display(Name = "NewPasswordVerification", ResourceType = typeof(Labels))]
[DataType(DataType.Password)]
public string NewPasswordVerification { get; set; }
```
```c#
RuleFor(m => m.NewPasswordVerification).Equal(m => m.NewPassword);
```

Output:
Nieuw wachtwoord [input field]
Nieuw wachtwoord bevestigen [input field] 'Nieuw wachtwoord bevestigen' moet gelijk zijn aan 'NewPassword'.
Comments: It's been a while,but I finally got back to this. The built-in validation attribute `[Compare("Foo")]` gets localised names for the source and the target of the comparison. I've also found why Fluent Validation does not get a localised name for the target of the comparison. In the `EqualToFluentValidationPropertyValidator` class, lines 26-28: ``` var formatter = new MessageFormatter() .AppendPropertyName(Rule.GetDisplayName()) .AppendArgument("ComparisonValue", propertyToCompare.Name); ``` So for `"ComparisonValue"` there's never an attempt made to get a localised name. I can write up a pull request but it'd probably not be in the right place in the codebase, unless you don't mind?

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>