You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
549 B
24 lines
549 B
using Connected.Middleware;
|
|
using Connected.Validation;
|
|
|
|
namespace 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);
|
|
}
|
|
}
|
|
} |