chore: rename internal types
Rename internal types in the validation to be more consistent with other projects
This commit is contained in:
parent
36f1a9eb1b
commit
c674de31f7
2 changed files with 35 additions and 31 deletions
|
|
@ -4,14 +4,11 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
[assembly: MetadataUpdateHandler(typeof(Geekeey.Request.Validation.DispatchingValidator))]
|
||||
|
||||
namespace Geekeey.Request.Validation;
|
||||
|
||||
internal sealed class DispatchingValidator : IValidator
|
||||
internal sealed partial class DispatchingValidator : IValidator
|
||||
{
|
||||
private static readonly ConcurrentDictionary<Type, ValidatorInvoker> ValidatorsHandlers = new();
|
||||
|
||||
|
|
@ -44,31 +41,4 @@ internal sealed class DispatchingValidator : IValidator
|
|||
|
||||
return handler.Validate(context, _serviceProvider);
|
||||
}
|
||||
|
||||
private abstract class ValidatorInvoker
|
||||
{
|
||||
public abstract Validation Validate(ValidationContext context, IServiceProvider serviceProvider);
|
||||
}
|
||||
|
||||
private sealed class ValidatorInvoker<T> : ValidatorInvoker
|
||||
{
|
||||
public override Validation Validate(ValidationContext context, IServiceProvider serviceProvider)
|
||||
{
|
||||
var options = serviceProvider.GetRequiredService<IOptions<RequestValidatorOptions>>().Value;
|
||||
|
||||
var validators = options.GetValidators<T>(serviceProvider);
|
||||
|
||||
var problems = new List<Problem>();
|
||||
|
||||
foreach (var validator in validators)
|
||||
{
|
||||
if (validator.Validate(context) is { IsValid: false, Problems: { } result })
|
||||
{
|
||||
problems.AddRange(result);
|
||||
}
|
||||
}
|
||||
|
||||
return new Validation(problems);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue