How to add validation to AddGenericEntityCommand
See original GitHub issueIt’s possible to overrideAddGenericEntityCommand
, but it’s not clear how to add validation.
adding this class:
class PostMyObjectCommandValidator : AbstractValidator<AddGenericEntityCommand<MyObjectEntity, int>>
{
public PostMyObjectCommandValidator()
{
RuleFor(request => request.Data.Id).Empty().Null();
RuleFor(request => request.Data.Age).NotEmpty().NotNull().GreaterThan(0);
RuleFor(request => request.Data.Name).NotEmpty().NotNull();
}
}
didn’t work
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Validate Entity in Entity Framework 6
You can write custom server side validation for any entity. To accomplish this, override the ValidateEntity method of DbContext as shown below.
Read more >Generic Validation
This enables all entity views to activate all the relevant custom validation logic without being tied to it. It also enables you to...
Read more >How to validate generic bean in REST service?
It very simple to use with other beans, for example: @RequestMapping(value = "/departments/{departmentId}/patterns", method = RequestMethod.POST ...
Read more >Add validation to entity classes - Visual Studio (Windows)
This topic provides the basic steps for adding validation to entity classes by using the O/R Designer. Because it might be difficult to...
Read more >Command & Query: Domain - Data validation
It's just needed to implement a generic validator that will use DataAnnotations to validate objects. Afterward simply decorate the objects' ...
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 Free
Top 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
I has clicked in your Link, it is a Issue.
I will reopen this issue.
Which template you are using?
This validation class has been created by the template?
If you are using CRUD Extension, you can implement validation like that https://github.com/fructuoso/LiquidCRUDExample/blob/main/src/Domain/Commands/AddProduct/AddProductCommandValidator.cs