You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if this whole process could be like a pluggable pipeline (kind of like middleware) where I can just slot in additional functionality. So initial example would just be to add a fluent validator based on each db model and use attributes like [Required] or [MaxLength(500)] to hint to the validation rules that will apply for that object.
publicclassMyClass{[Required]publicstringName{get;set;}[MaxLength(500)]publicstringDescription{get;set;}}publicclassMyClassValidator:AbstractValidator<MyClass>{publicMyClassValidator(){RuleFor(request =>request.Name).Must(x =>!string.IsNullOrWhiteSpace(x)).WithMessage(x =>"Name is required!");RuleFor(request =>request.Description).MaximumLength(500).WithMessage(x =>"Description must be less than 500 characters!");}}
The text was updated successfully, but these errors were encountered:
This is a bit awkward though as the more I think about it, the less I think validation attributes belong in domain models. They are better suited at a dto level so it would be nice if anyone has any suggestions for how they think this could be done.
For me it boils down to the fact that most endpoints will have some form of validation, so if I have to hand crank all of those, where is the benefit here?
It would be nice if this whole process could be like a pluggable pipeline (kind of like middleware) where I can just slot in additional functionality. So initial example would just be to add a fluent validator based on each db model and use attributes like [Required] or [MaxLength(500)] to hint to the validation rules that will apply for that object.
The text was updated successfully, but these errors were encountered: