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.

Outsourcing validators to separate class-lib is not possible

See original GitHub issue

I have the following project setup: Screenshot from 2022-08-14 15-12-59

My requests, responses and validators are living outside of the API project that references FastEndpoints in a project called Contract. This is done to allow for easy integration of requests, responses and validators into the API and Blazor frontends.

Due to changes in #141 AbstractValidator<T> instances are no longer registered by FastEndpoints, so this doesn’t work any longer. Installing FastEndpoints into the Contract class lib is not an option as this will break Blazor WASM with the following error:

Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
dj-nitehawkcommented, Aug 20, 2022

guys give v5.0.0-beta7 a whirl…

so… by default only validators inheriting from FastEndpoints.Validator<TRequest> are auto discovered and registered.

if someone wants to include FluentValidation.AbstractValidator<TRequest> validators as well, all they gotta do is:

builder.Services.AddFastEndpoints(o => o.IncludeAbstractValidators = true);

an exception will be thrown during startup if more than one validator is found for a single request dto. in which case the user needs to be explicit about which exact validator must be used in the endpoint configuration like so:

    public override void Configure()
    {
        Get("test");
        Validator<MyValidator>();
    }

beta docs updated: https://dev--fast-endpoints.netlify.app/docs/validation#abstract-validator-classes

so… what do you think? have i missed anything?

1reaction
dj-nitehawkcommented, Aug 17, 2022

you can ignore the generator for now. I’ll look in to it later. for now it can be a limitation of the generator package. i.e. it will discover all validators.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting validators in classLibrary automatically with .net ...
When there is a "Validations" folder under InventoryManagement.Services, validations do not work. But when I import the "Validations" folder ...
Read more >
Adding a Procedure to Multiple Objects - Microsoft: FoxPro
If all the textboxes are based on the same class, you could simply add the required code to the Valid of the class,...
Read more >
Michele Chubirka's Post
ClassLib.SILGlobals to save the global variables to the current session. These variables are stored in the sessionvars SQL table. When another request is...
Read more >
Modern API Design with ASP.NET Core 2
Finally, you'll examine not only how to deploy your code to on-premises servers or ... NET Core–based and another that is based on...
Read more >
SignalR on .NET 6 - the Complete Guide
5 - Sending messages to individual clients or groups of clients . ... has limited bandwidth to work with, you may not even...
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