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.

Possible Enhancement: Modification of value to be verified in RuleFor

See original GitHub issue

First off, great library. Thanks for the excellent work here. But I was looking for one feature and I couldn’t find it. I think it may be an enhancement that could be useful to many developers.

In my domain, we get a lot of untrimmed strings, prefixed strings and so on. What I want to validate is a transformed value, not the original value. An example follows.

RuleFor(m => m.TransactionId).Transform(t => t.TrimStart("0")).NotEmpty()

It is true that this can be done in custom rules or using Must, but I’m wondering if there is enough interest and use of this pattern to make something like this available. It seems more fluent to me in a way that just using Must.

Interested in feedback and discussion, if enough interest exists, I (or others) can explore how to best add to the library if it makes sense. I totally accept that such as change may not be practical or expedient.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Feb 26, 2018

I’ve released 7.5 to nuget today that includes this fix.

1reaction
JeremySkinnercommented, Feb 15, 2018

Re-opening to track development progress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - FluentValidation: Update the validated model for some ...
Hi, FluentValidation only performs validation on a pre-populated object, it doesn't modify/change the values of properties.
Read more >
Overriding the Message — FluentValidation documentation
You can override the default error message for a validator by calling the WithMessage method on a validator definition: RuleFor(customer => customer.
Read more >
Validating Objects With FluentValidation
In this article, we'll learn how to use the FluentValidation library and create simple and strongly typed validations.
Read more >
Proposed Rule
The Enhancement and Standardization of Climate-Related Disclosures for Investors. AGENCY: Securities and Exchange Commission.
Read more >
Define Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the...
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