question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add validation to AddGenericEntityCommand

See original GitHub issue

It’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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fructuosocommented, Feb 28, 2022

I has clicked in your Link, it is a Issue.

I will reopen this issue.

0reactions
fructuosocommented, Feb 28, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found