21 lines
652 B
C#
21 lines
652 B
C#
using AutobusApi.Domain.Enums;
|
|
using FluentValidation;
|
|
|
|
namespace AutobusApi.Application.Addresses.Commands.CreateAddress;
|
|
|
|
public class CreateAddressCommandValidator : AbstractValidator<CreateAddressCommand>
|
|
{
|
|
public CreateAddressCommandValidator()
|
|
{
|
|
RuleFor(v => v.Name).MinimumLength(2).MaximumLength(64);
|
|
|
|
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 _));
|
|
}
|
|
}
|