(InvalidCharacterError with Datetime (Localized?)
See original GitHub issueWhich version of FluentValidation are you using? Please specify which version of FluentValidation you’re using. 9.1.1
Which version of ASP.NET are you using? If you are using FluentValidation with ASP.NET, please provide the version of ASP.NET that you’re using (eg .NET Core 2.1, NET Core 3.1 etc) ASP.Net Blazor 3.1 On FireFox 79.0
Describe the issue that you’re having A clear and concise description of the issue that you’re having, steps to reproduce, and sample code to reproduce the issue.
When I use a date with fluentvalidation, it always fail with an error:
System.AggregateException: One or more errors occurred. (InvalidCharacterError: String contains an invalid character) —> System.InvalidOperationException: InvalidCharacterError: String contains an invalid character at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
My OS is in french, I tried to set CultureInfo.DefaultThreadCurrentCulture and DefaultThreadCurrentUICulture in english even with CultureInfo.InvariantCulture; it don’t work.
The classes used:
public class Person
{
public string PersonName { get; set; }
public DateTime? PersonBirthDate { get; set; }
}
public class PersonValidator : AbstractValidator<Person>
{
public PersonValidator()
{
RuleFor(r => r.PersonName).NotEmpty().WithMessage("The name counld not be empty!");
RuleFor(r => r.PersonBirthDate).Must(BirthDateValidator).WithMessage("Error date!");
}
private bool BirthDateValidator(DateTime? date)
{
return !(date == null || (date < DateTime.Now.AddYears(-99) || date > DateTime.Now.AddYears(-18)));
}
}
GitHub Source: https://github.com/frablaser/ErrorDateFireFox
Issue Analytics
- State:
- Created 3 years ago
- Comments:25 (11 by maintainers)
Top GitHub Comments
This is a Mozilla thing, it store the culture in the cookies… If you flush the recent cookies it should works.
I’m totally stuck… With Blazor Server side, I have to manipulate the cookies to get rid of the culture, it will totally disturb all my web site, that’s not a solution. It’s funny that in 2020 there still some date unmanagement like that. I have to drop FV or my site Localization… 🙄 I’ll wait for the Blazor team to see if the can fix it…
Thanks anyway Jeremy for your support, the day where I’ll do money with my site, I’ll come back to pay you a good tip.
Best regards Francis
I’ll will knock on that door too! Why not! 😉👍
Regards