New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change to handling DateTime in LessThanOrEqualTo #1721
Comments
Hi, thanks for reporting this. It looks like the call to LessThan is emitting the wrong clientside metadata. FluentValidation doesn’t perform clientside validation directly but rather exports metadata which is then used by asp.net to generate the markup and perform clientside validation. Asp.net doesn’t have clientside validator equivalents for GreaterThan/LessThan, so FluentValidation shouldn’t emit clientside metadata for these, so I think this is a bug where metadata is being exported for the wrong thing, from the markup it looks like it’s generating markup for Range validation (which should only be triggered for InxlusiveBetween). I’ll have a look at what’s going on and try and get this fixed today. |
Awesome. Thank you. |
… of LessThanOrEqual/GreaterThanOrEqual (#1721)
This is fixed, and I've pushed out the 10.1 release to nuget. Please give it a try and let me know if you run into any further issues. Some background if you're interested: the Internally, the |
That has fixed the problem. Thanks. The explanation is definitely interesting. It gives an insight in to what is happening 'under the covers'. Very cool. |
FluentValidation version
10.0.4
ASP.NET version
.NET 5
Summary
There appears to be a difference in the
LessThanOrEqualTo
handling client-side (in my case forDateTime
) going from 9.5.4 to 10.0.4. This is causing client-side validation to incorrectly fail for valid cases.I have read through the upgrade guide and the only change made was going from
services.AddTransient
toservices.AddScoped
.Leaving the
services.AddScoped
in place and simply flipping the package version back and forth reproduces the issue.Steps to Reproduce
The validators are checking that the start date is before the end date:
The HTML/Razor is:
The input field for the start date changes but all other HTML remains the same.
The resultant HTML for 9.5.4 is:
The resultant HTML for 10.0.4 is:
This change causes client-side validation to fail with a message that 'End date must be after Start date.' with a value of 28/03/201 for start and 28/04/2021 for the end date.
The text was updated successfully, but these errors were encountered: