Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ env:
JAVA_VERSION: 17
JAVA_DISTRIBUTION: microsoft
DOTNET_VERSION: |
3.1.x
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x
DOTNET_BUILD_CONFIGURATION: Release
SONAR_PATH: .\.sonar\scanner
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -29,18 +27,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Set up .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: FluentValidation.AutoValidation [Release]

env:
DOTNET_VERSION: 9.0.x
DOTNET_VERSION: 10.0.x
DOTNET_BUILD_CONFIGURATION: Release
DOTNET_PACKAGES_OUTPUT_DIRECTORY: .nuget
NUGET_SOURCE: https://api.nuget.org/v3/index.json
Expand All @@ -18,12 +18,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<NoWarn>NU1701</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<AssemblyName>SharpGrip.FluentValidation.AutoValidation.Endpoints</AssemblyName>
<PackageId>SharpGrip.FluentValidation.AutoValidation.Endpoints</PackageId>
<Title>SharpGrip FluentValidation AutoValidation Endpoints</Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AssemblyName>SharpGrip.FluentValidation.AutoValidation.Mvc</AssemblyName>
<PackageId>SharpGrip.FluentValidation.AutoValidation.Mvc</PackageId>
<Title>SharpGrip FluentValidation AutoValidation MVC</Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AutoValidationMvcConfiguration

/// <summary>
/// Configures the validation strategy. Validation strategy <see cref="Enums.ValidationStrategy.All"/> enables asynchronous automatic validation on all controllers inheriting from <see cref="ControllerBase"/>.
/// Validation strategy <see cref="Enums.ValidationStrategy.Annotations"/> enables asynchronous automatic validation on controllers inheriting from <see cref="ControllerBase"/> decorated (class or method) with a <see cref="FluentValidationAutoValidationAttribute"/> attribute.
/// Validation strategy <see cref="Enums.ValidationStrategy.Annotations"/> enables asynchronous automatic validation on controllers decorated (class or method) with a <see cref="AutoValidationAttribute"/> attribute.
/// </summary>
public ValidationStrategy ValidationStrategy { get; set; } = ValidationStrategy.All;

Expand Down Expand Up @@ -70,7 +70,7 @@ public class AutoValidationMvcConfiguration
/// The default result factory returns the default <see cref="ValidationProblemDetails"/> object wrapped in a <see cref="BadRequestObjectResult"/>>.
/// </summary>
/// <see cref="FluentValidationAutoValidationDefaultResultFactory"/>
/// <typeparam name="TResultFactory">The custom result factory implement <see cref="IFluentValidationAutoValidationResultFactory"/>.</typeparam>
/// <typeparam name="TResultFactory">The custom result factory implementing <see cref="IFluentValidationAutoValidationResultFactory"/>.</typeparam>
public void OverrideDefaultResultFactoryWith<TResultFactory>() where TResultFactory : IFluentValidationAutoValidationResultFactory
{
OverriddenResultFactory = typeof(TResultFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum ValidationStrategy
All = 1,

/// <summary>
/// Enables asynchronous automatic validation on controllers inheriting from <see cref="ControllerBase"/> decorated with a <see cref="FluentValidationAutoValidationAttribute"/> attribute.
/// Enables asynchronous automatic validation on controllers inheriting from <see cref="ControllerBase"/> decorated with a <see cref="AutoValidationAttribute"/> attribute.
/// </summary>
Annotations = 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AssemblyName>SharpGrip.FluentValidation.AutoValidation.Shared</AssemblyName>
<PackageId>SharpGrip.FluentValidation.AutoValidation.Shared</PackageId>
<Title>SharpGrip FluentValidation AutoValidation Shared</Title>
Expand Down
13 changes: 6 additions & 7 deletions Tests/FluentValidation.AutoValidation.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<RootNamespace>SharpGrip.FluentValidation.AutoValidation.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.console" Version="2.9.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.msbuild" Version="2.9.2">
<PackageReference Include="xunit.runner.msbuild" Version="2.9.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using FluentValidation.Results;
// ReSharper disable InconsistentNaming

using FluentValidation.Results;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using SharpGrip.FluentValidation.AutoValidation.Endpoints.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// ReSharper disable InconsistentNaming

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
// ReSharper disable InconsistentNaming

using System.Collections.Generic;
using FluentValidation.Results;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
// ReSharper disable InconsistentNaming

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task TestOnActionExecutionAsync()
Parameter2 = "Value 2",
Parameter3 = "Value 3"
}
},
}
};
var controllerActionDescriptor = new ControllerActionDescriptor
{
Expand Down Expand Up @@ -129,7 +129,7 @@ public async Task OnActionExecutionAsync_WithInstanceTypeDifferentThanParameterT
{
Parameters =
[
new()
new ParameterDescriptor
{
Name = "request",
ParameterType = typeof(CreateAnimalRequest),
Expand Down Expand Up @@ -169,46 +169,35 @@ public async Task OnActionExecutionAsync_WithInstanceTypeDifferentThanParameterT
// Assert
var modelStateDictionaryValues = modelStateDictionary.Values.ToList();
var validationFailuresValues = validationFailures.Values.ToList();
var badRequestObjectResult = (BadRequestObjectResult)actionExecutingContext.Result!;
var badRequestObjectResultValidationProblemDetails = (ValidationProblemDetails)badRequestObjectResult.Value!;
var badRequestObjectResult = (BadRequestObjectResult) actionExecutingContext.Result!;
var badRequestObjectResultValidationProblemDetails = (ValidationProblemDetails) badRequestObjectResult.Value!;

Assert.Contains(validationFailuresValues[0].First(), modelStateDictionaryValues[0].Errors.Select(error => error.ErrorMessage));
Assert.Contains(validationFailuresValues[0].First(), badRequestObjectResultValidationProblemDetails.Errors[nameof(CreatePersonRequest.Name)][0]);
}

public class AnimalsController : ControllerBase
{
}
public class AnimalsController : ControllerBase;

public class CreateAnimalRequest
{
}
public class CreateAnimalRequest;

public class CreatePersonRequest : CreateAnimalRequest
{
public required string Name { get; set; }
}

public class CreateAnimalRequestValidator : AbstractValidator<CreateAnimalRequest>
{
public CreateAnimalRequestValidator()
{
}
}
public class CreateAnimalRequestValidator : AbstractValidator<CreateAnimalRequest>;

public class CreatePersonRequestValidator : AbstractValidator<CreatePersonRequest>
{
public CreatePersonRequestValidator()
{
this.Include(new CreateAnimalRequestValidator());
Include(new CreateAnimalRequestValidator());

this.RuleFor(x => x.Name).Equal("John Doe");
RuleFor(x => x.Name).Equal("John Doe");
}
}

public class TestController : ControllerBase
{
}
public class TestController : ControllerBase;

private class TestModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
// ReSharper disable InconsistentNaming

using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
Expand All @@ -14,9 +16,9 @@ public class FluentValidationAutoValidationDefaultResultFactoryTest
{
private static readonly Dictionary<string, string[]> ValidationFailures = new()
{
{"Property 1", new[] {"Error message 1"}},
{"Property 2", new[] {"Error message 2"}},
{"Property 3", new[] {"Error message 3"}},
{"Property 1", ["Error message 1"]},
{"Property 2", ["Error message 2"]},
{"Property 3", ["Error message 3"]},
};

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// ReSharper disable InconsistentNaming

using System;
using FluentValidation;
using NSubstitute;
using SharpGrip.FluentValidation.AutoValidation.Shared.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// ReSharper disable InconsistentNaming

using System;
using Microsoft.AspNetCore.Mvc;
using SharpGrip.FluentValidation.AutoValidation.Mvc.Attributes;
using SharpGrip.FluentValidation.AutoValidation.Shared.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
// ReSharper disable InconsistentNaming

using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
using SharpGrip.FluentValidation.AutoValidation.Shared.Extensions;
Expand Down
Loading