-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Richard87-issue-478-bugfix'
- Loading branch information
Showing
18 changed files
with
257 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Http/Wolverine.Http.Tests.DifferentAssembly/Validation/ValidatedEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using FluentValidation; | ||
|
||
namespace Wolverine.Http.Tests.DifferentAssembly.Validation; | ||
|
||
public class Validated2Endpoint | ||
{ | ||
[WolverinePost("/validate2/customer")] | ||
public static string Post(CreateCustomer2 customer) | ||
{ | ||
return "Got a new customer"; | ||
} | ||
|
||
[WolverinePost("/validate2/user")] | ||
public static string Post(CreateUser2 user) | ||
{ | ||
return "Got a new user"; | ||
} | ||
} | ||
|
||
public record CreateCustomer2 | ||
( | ||
string FirstName, | ||
string LastName, | ||
string PostalCode | ||
) | ||
{ | ||
public class CreateCustomerValidator : AbstractValidator<CreateCustomer2> | ||
{ | ||
public CreateCustomerValidator() | ||
{ | ||
RuleFor(x => x.FirstName).NotNull(); | ||
RuleFor(x => x.LastName).NotNull(); | ||
RuleFor(x => x.PostalCode).NotNull(); | ||
} | ||
} | ||
} | ||
|
||
public record CreateUser2 | ||
( | ||
string FirstName, | ||
string LastName, | ||
string PostalCode, | ||
string Password | ||
) | ||
{ | ||
public class CreateUserValidator : AbstractValidator<CreateUser2> | ||
{ | ||
public CreateUserValidator() | ||
{ | ||
RuleFor(x => x.FirstName).NotNull(); | ||
RuleFor(x => x.LastName).NotNull(); | ||
RuleFor(x => x.PostalCode).NotNull(); | ||
} | ||
} | ||
|
||
public class PasswordValidator : AbstractValidator<CreateUser2> | ||
{ | ||
public PasswordValidator() | ||
{ | ||
RuleFor(x => x.Password).Length(8); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...Http/Wolverine.Http.Tests.DifferentAssembly/Wolverine.Http.Tests.DifferentAssembly.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Wolverine.Http\Wolverine.Http.csproj" /> | ||
<ProjectReference Include="..\Wolverine.Http.FluentValidation\Wolverine.Http.FluentValidation.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate2_customer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <auto-generated/> | ||
#pragma warning disable | ||
using FluentValidation; | ||
using Microsoft.AspNetCore.Routing; | ||
using System; | ||
using System.Linq; | ||
using Wolverine.Http; | ||
using Wolverine.Http.FluentValidation; | ||
|
||
namespace Internal.Generated.WolverineHandlers | ||
{ | ||
// START: POST_validate2_customer | ||
public class POST_validate2_customer : Wolverine.Http.HttpHandler | ||
{ | ||
private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; | ||
private readonly Wolverine.Http.FluentValidation.IProblemDetailSource<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2> _problemDetailSource; | ||
private readonly FluentValidation.IValidator<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2> _validator; | ||
|
||
public POST_validate2_customer(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Http.FluentValidation.IProblemDetailSource<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2> problemDetailSource, FluentValidation.IValidator<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2> validator) : base(wolverineHttpOptions) | ||
{ | ||
_wolverineHttpOptions = wolverineHttpOptions; | ||
_problemDetailSource = problemDetailSource; | ||
_validator = validator; | ||
} | ||
|
||
|
||
|
||
public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) | ||
{ | ||
var (customer, jsonContinue) = await ReadJsonAsync<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2>(httpContext); | ||
if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; | ||
var result1 = await Wolverine.Http.FluentValidation.Internals.FluentValidationHttpExecutor.ExecuteOne<Wolverine.Http.Tests.DifferentAssembly.Validation.CreateCustomer2>(_validator, _problemDetailSource, customer).ConfigureAwait(false); | ||
if (!(result1 is Wolverine.Http.WolverineContinue)) | ||
{ | ||
await result1.ExecuteAsync(httpContext).ConfigureAwait(false); | ||
return; | ||
} | ||
|
||
var result_of_Post = Wolverine.Http.Tests.DifferentAssembly.Validation.Validated2Endpoint.Post(customer); | ||
await WriteString(httpContext, result_of_Post); | ||
} | ||
|
||
} | ||
|
||
// END: POST_validate2_customer | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.