question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How could we convert a displayed property value before it gets displayed.

See original GitHub issue

Hi everyone,

I’m currently trying to figure out how I could implement an extension in FluentValidation to be able to convert the displayed value of a property. This might seems strange, but in the framework we are using right now, some values are saved in specific units but displayed in another one. Therefore, I would like the validation to display the unit correctly.

As an example, I might have a class with a property Weight that is saved in kg but displayed in lb. When I do validate the property using Fluent Validation, the value that is being validated is in kg (which is good), but the error displayed is in kg (which is bad).

I know that I could have override all the validation to use custom message, but I was trying to find an easier solution. I’ve tried to replace some of the Fluent Validation option, but some classes are not accessible (they are internal). Therefore I’m a little bit stuck.

The other solution would be to validate the converted unit, which would work but requires some changes in the current framework, which I don’t think is a good solution.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Jan 28, 2018

Thanks, I’m glad its working. I’ll close this for now.

For the next release I’ll extend this to make AbstractComparisonValidator.GetComparisonValue public too.

1reaction
JeremySkinnercommented, Jan 26, 2018

How’re you defining your rule? It should be populated if the comparison is a constant value. If you’re comparing to another property then MemberToCompare will be populated instead. You could also retrieve it from the MessageFormatter (which I think you were doing before)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change value of display property after it has been ...
So my issue is something like this: When I click the Login button and the user has entered invalid credentials, I display an...
Read more >
CSS Layout - The display Property
The display property specifies if/how an element is displayed. Every HTML element has a default display value depending on what type of element...
Read more >
How To Use the Display Property to Manipulate the Box ...
The value of the CSS display property affects the box model, the mechanism that determines how elements interact with one another on a...
Read more >
Demystifying The CSS Display Property
The CSS display property sets how HTML elements display on your browser and the layout flow. The display property has about seven major...
Read more >
When can we change a site property value?
1. Site property values can only be changed in the service center (I choose this one :( ) · 2. Site properties can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found