autobus-api_old/AutobusApi.Application/Addresses/Commands/UpdateAddress/UpdateAddressCommandValidator.cs

23 lines
696 B
C#

using AutobusApi.Domain.Enums;
using FluentValidation;
namespace AutobusApi.Application.Addresses.Commands.UpdateAddress;
public class UpdateAddressCommandValidator : AbstractValidator<UpdateAddressCommand>
{
public UpdateAddressCommandValidator()
{
RuleFor(v => v.Name).MinimumLength(2).MaximumLength(64);
RuleFor(v => v.Id).GreaterThan(0);
RuleFor(v => v.CityId).GreaterThan(0);
RuleFor(v => v.Latitude).GreaterThanOrEqualTo(-180).LessThanOrEqualTo(180);
RuleFor(v => v.Longitude).GreaterThanOrEqualTo(-180).LessThanOrEqualTo(180);
RuleFor(v => v.VehicleType).Must(value => Enum.TryParse<VehicleType>(value, true, out _));
}
}