IsInEnum() does not support custom messages
See original GitHub issueSystem Details
- FluentValidation version: v8.4.0
- Web Framework version: dotnet core 2.2
Issue Description
If I have an enum and I want to set a custom error message, it always appear the default one.
RuleFor(t=> t.MyEnum).IsInEnum().WithMessage("Failed");
Instead of the error be Failed
is always The value 'X' is invalid.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Use my custom FluentValidation error message instead of ...
I have tried RuleFor(x => x.Category.ToString()).IsEnumName(typeof(Category)); but had no success. Do you know how can I use my message error?
Read more >Built-in Validators — FluentValidation documentation
NotEmpty Validator¶. Ensures that the specified property is not null, an empty string or whitespace (or the default value for value types, e.g.,...
Read more >Built-In, Nested, Custom Validators with FluentValidation
In this article we are going to learn more about different Validators with FluentValidation, that we can use to protect our app from...
Read more >Fluent Validation for .NET - RSSing.com
IsInEnum <DayOfWeek>();. Now I need to test the validator- not test my data with the validator, but to test the validator itself. The...
Read more >Validations for Enum Types
Learn how to build validations for enums using Java custom annotations.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To clarify it’s not needed only when using automatic validation. You can still use it in asp.net projects when validating manually
Because FluentValidation actually pre-dates asp.net mvc (and automatic model binding), and is used widely in many scenarios outside of asp.net’s automatic validation.
It can be used to manually validate objects (eg domain models or commands) and It’s regularly used outside of web projects too (eg in desktop apps).