24 lines
559 B
C#
24 lines
559 B
C#
using Connected.Middleware;
|
|
using Connected.Validation;
|
|
|
|
namespace Connected.Logistics.Types.Serials;
|
|
internal sealed class InsertSerialValidator : MiddlewareComponent, IValidator<InsertSerialArgs>
|
|
{
|
|
public InsertSerialValidator(ISerialService serials)
|
|
{
|
|
Serials = serials;
|
|
}
|
|
|
|
public ISerialService Serials { get; }
|
|
|
|
public async Task Validate(InsertSerialArgs args)
|
|
{
|
|
if (await Serials.Select(new SelectSerialArgs
|
|
{
|
|
Value = args.Value
|
|
}) is not null)
|
|
{
|
|
throw ValidationExceptions.ValueExists(nameof(args.Value), args.Value);
|
|
}
|
|
}
|
|
} |