Тёмный

Fluent Validation in MediatR with Results 

Ardalis
Подписаться 13 тыс.
Просмотров 5 тыс.
50% 1

Fluent Validation in MediatR with Results
Hey everyone, I'm Steve Smith aka ardalis, of NimblePros!
In this video we extend the previous video's MediatR behavior-based validation to work with a Result abstraction. In this way, we're able to return the validation errors back to the API endpoint in a way that allows it to return a 400 Bad Request rather than just a 500 Server Error.
Get The Source Code
mailchi.mp/ard...
Links
github.com/ard...
github.com/jbo...
github.com/Flu...
github.com/ard...
C# Generics Best Practices Course:
www.pluralsigh...
Check out my courses:
ardalis.com/tr...
www.pluralsigh...
Consulting and Training: NimblePros.com and @nimblepros
Developer Group Mentoring: devBetter.com
Free Weekly Email Tips:
ardalis.com/tips/
If you read this far, I hope you liked the video and consider subscribing to my channel!
Find me:
ardalis.com
/ ardalis
github.com/ard...
/ stevenandrewsmith
bsky.app/profi...
#dotnet #deviq #ardalis #nimblepros #visualstudio #csharp #designpatterns #nuget #cleancode #validation #fluentvalidation #result #cleanarchitecture #mediatr #chainofresponsibility

Опубликовано:

 

6 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 14   
@ahmad.mozaffar
@ahmad.mozaffar 9 месяцев назад
I was a big exceptions fan with centralized error handlers, but suddenly with a quick pass to your repo, everything has changed. Result is a super smart idea
@bloopers2967
@bloopers2967 9 месяцев назад
You should upload more often, we really like your videos
@Ardalis
@Ardalis 8 месяцев назад
Hoping to get on a regular weekly schedule but other deadlines keep intruding.
@OzgulEzgin
@OzgulEzgin 9 месяцев назад
Great video Steve, thanks. Also the hat is much better than the other one 😁
@Ardalis
@Ardalis 9 месяцев назад
I think so too! The dotnet bucket hat is a little too small - maybe just due to my longer hair!
@OzgulEzgin
@OzgulEzgin 9 месяцев назад
@@Ardalis 😊 keep up the good work 🍀
@path_selector
@path_selector 9 месяцев назад
nice video, i preferred the directors cut that was previously uploaded tho. ;)
@Ardalis
@Ardalis 9 месяцев назад
Heh, thanks. Yeah that one had no edits and was like 4 minutes longer so this one wastes less of your time. :)
@deliriuspixel8743
@deliriuspixel8743 4 месяца назад
Hello. I have watched all of your videos regarding mediatr domain fluent validation but there is one concept I am struggling with. Lets say I have an expensive business rule that I need to validate for an insert command. This rule can only be checked by going to a repository through DI. It is my understanding that expensive business rules exist in the domain layer. But a domain object should always be valid and domain objects are just created new and not injected. So from my research, it appears I would make a domain service? And that service would be injected into the mediatr command as an additonal check but then now youre having to do isvalid on domain objects which violates a principal? Tldr where the heck do I put expensive business validation that must go gather additional values to compare against within this design architecture. Love ur stuff. Sorry for writing a book.
@Ardalis
@Ardalis 4 месяца назад
Answered via email - hth.
@igeoorge3g
@igeoorge3g 3 месяца назад
It looks like everybody is validating commands using fluent validation Wich is really good. But what about the client request model validation? It is supposed that the request should be valid and then you map to the command and go into the mediator behaviors. I recently implemented the MiniValidator only for client requests using an iendpointfilter and the old well known data annotations. Is there a why? Any comments
@Ardalis
@Ardalis 2 месяца назад
I typically use the built-in model validation if I'm using MVC controllers for the APIs (using the [ApiController] attribute, typically) or if I'm using FastEndpoints, it has built-in support for validator classes that basically use FluentValidation, too. I'm also typically fine to just do the validation at the ApplicationServices / UseCases level and return an Ardalis.Result which, if the result is Invalid, I can easily map to an IResult/ActionResult of 400 Bad Request using Ardalis.Result.AspNetCore package and its helpers.
@pickle1987
@pickle1987 4 месяца назад
Hello, Thanks for the videos I was wondering if there is a way to avoid reflexion (for performance reasons) ?
@Ardalis
@Ardalis 4 месяца назад
Depends on the specific scenario. In what context?
Далее
When To Validate and When To Throw Exceptions?
11:00
REPR and Clean Architecture
11:48
Просмотров 16 тыс.
POLI и Маша - Сигма бой
00:20
Просмотров 295 тыс.
Find The Real MrBeast, Win $10,000
00:37
Просмотров 37 млн
@ItsMamix учу делать сигму😎
00:12
Просмотров 679 тыс.
The New Option and Result Types of C#
15:05
Просмотров 71 тыс.
5 Rules For DTOs
17:56
Просмотров 42 тыс.
Being Competent With Coding Is More Fun
11:13
Просмотров 90 тыс.
Building Fluent Interfaces in TypeScript
16:15
Просмотров 16 тыс.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Forget Controllers and Minimal APIs in .NET!
14:07
Просмотров 70 тыс.
The Logging Everyone Should Be Using in .NET
15:34
Просмотров 72 тыс.
Interfaces: WHAT - Implementations: HOW
5:35
Просмотров 1,3 тыс.
POLI и Маша - Сигма бой
00:20
Просмотров 295 тыс.