mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-01 04:43:13 +00:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
|
|
using FluentValidation;
|
||
|
|
using ProposalSystem.Application.DTOs;
|
||
|
|
|
||
|
|
namespace ProposalSystem.Application.Validators;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// PR5: Validates CreatePricingLibraryItemRequest payloads.
|
||
|
|
/// </summary>
|
||
|
|
public class CreatePricingLibraryItemValidator : AbstractValidator<CreatePricingLibraryItemRequest>
|
||
|
|
{
|
||
|
|
public CreatePricingLibraryItemValidator()
|
||
|
|
{
|
||
|
|
RuleFor(x => x.Title)
|
||
|
|
.NotEmpty().WithMessage("Title is required")
|
||
|
|
.MaximumLength(200);
|
||
|
|
|
||
|
|
RuleFor(x => x.Description)
|
||
|
|
.MaximumLength(5000)
|
||
|
|
.When(x => x.Description != null);
|
||
|
|
|
||
|
|
RuleFor(x => x.ServiceCategory).IsInEnum();
|
||
|
|
|
||
|
|
RuleFor(x => x.Unit)
|
||
|
|
.MaximumLength(50)
|
||
|
|
.When(x => x.Unit != null);
|
||
|
|
|
||
|
|
RuleFor(x => x.UnitPrice)
|
||
|
|
.GreaterThanOrEqualTo(0).WithMessage("Unit price must be zero or positive")
|
||
|
|
.When(x => x.UnitPrice.HasValue);
|
||
|
|
|
||
|
|
RuleFor(x => x.Keywords)
|
||
|
|
.MaximumLength(2000)
|
||
|
|
.When(x => x.Keywords != null);
|
||
|
|
|
||
|
|
RuleFor(x => x.Source)
|
||
|
|
.MaximumLength(100)
|
||
|
|
.When(x => x.Source != null);
|
||
|
|
}
|
||
|
|
}
|