CustomizeValidatorAttribute on razor page actions don't work
See original GitHub issueRulesets (and skip) specified with CustomizeValidatorAttribute (on razor pages model actions) don’t work on asp.net core 2.1 razor pages. Properties work fine. I tested manual validation and it works fine. So, I tried the configuration options like ImplicitlyValidateChildProperties but did not help.
My rules are simple like this;
public class PersonValidator : AbstractValidator<Person> {
public PersonValidator() {
RuleFor(x => x.Id).NotNull();
RuleFor(x => x.Name).Length(0, 10);
RuleFor(x => x.Email).EmailAddress();
RuleFor(x => x.Age).InclusiveBetween(18, 60);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Model validation in ASP.NET Core MVC and Razor Pages
Validation attributes let you specify validation rules for model properties. The following example from the sample app shows a model class that ...
Read more >How do I add custom validation to a Razor page? [duplicate]
1 Answer. To do custom validation, you want to inherit from IValidatableObject .
Read more >User Input Validation in Razor Pages
Input Validation is the process whereby you ensure that values provided by the user of your Razor Pages web site are of the...
Read more >CompareAttribute not working properly with bound ...
One possibility would be to validate the page model itself, passing a custom IValidationStrategy to ignore properties that were not bound. ( ...
Read more >Server & Client side Validations in MVC and Razor Pages
A Complete tutorial of how we can apply server & client side validation for MVC and Razor Pages with localization.
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
If you don’t want automatic validation then just don’t call AddFluentValidation in your application startup.
Hi, the CustomizeValidatorAttribute can only be used on regular controller action parameters. It can’t be used on the page models in this way. We can look at supporting this in a future version, but I believe that asp.net core 2.1 doesn’t have the infrastructure to support this so this may have to wait until 3.0.