mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 09:33:13 +00:00
Stop client writes from changing Locations.AccountId, make the SH-221 migration discoverable, and thread the board-create CancellationToken through lookup and persistence.
65 lines
2.4 KiB
C#
65 lines
2.4 KiB
C#
using FluentValidation;
|
|
using SeaHaven.Services.DTOs;
|
|
|
|
namespace SeaHaven.Services.Validation
|
|
{
|
|
public interface ICreateLocationValidation : IValidator<CreateLocationDTO>
|
|
{
|
|
}
|
|
|
|
public class CreateLocationValidation : AbstractValidator<CreateLocationDTO>, ICreateLocationValidation
|
|
{
|
|
public CreateLocationValidation()
|
|
{
|
|
RuleFor(x => x.LocationName)
|
|
.NotEmpty().WithMessage("Location name is required")
|
|
.MaximumLength(200).WithMessage("Location name cannot exceed 200 characters");
|
|
|
|
RuleFor(x => x.Address)
|
|
.MaximumLength(500).WithMessage("Address cannot exceed 500 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.Address));
|
|
|
|
RuleFor(x => x.City)
|
|
.MaximumLength(100).WithMessage("City cannot exceed 100 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.City));
|
|
|
|
RuleFor(x => x.State)
|
|
.MaximumLength(2).WithMessage("State must be 2 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.State));
|
|
|
|
RuleFor(x => x.Zipcode)
|
|
.MaximumLength(10).WithMessage("Zipcode cannot exceed 10 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.Zipcode));
|
|
}
|
|
}
|
|
|
|
public interface IUpdateLocationValidation : IValidator<UpdateLocationDTO>
|
|
{
|
|
}
|
|
|
|
public class UpdateLocationValidation : AbstractValidator<UpdateLocationDTO>, IUpdateLocationValidation
|
|
{
|
|
public UpdateLocationValidation()
|
|
{
|
|
RuleFor(x => x.LocationName)
|
|
.MaximumLength(200).WithMessage("Location name cannot exceed 200 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.LocationName));
|
|
|
|
RuleFor(x => x.Address)
|
|
.MaximumLength(500).WithMessage("Address cannot exceed 500 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.Address));
|
|
|
|
RuleFor(x => x.City)
|
|
.MaximumLength(100).WithMessage("City cannot exceed 100 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.City));
|
|
|
|
RuleFor(x => x.State)
|
|
.MaximumLength(2).WithMessage("State must be 2 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.State));
|
|
|
|
RuleFor(x => x.Zipcode)
|
|
.MaximumLength(10).WithMessage("Zipcode cannot exceed 10 characters")
|
|
.When(x => !string.IsNullOrEmpty(x.Zipcode));
|
|
}
|
|
}
|
|
}
|