feature: Warning Alert Consumer, Orders API & Input Validation
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class AlertThresholdRequestValidator : AbstractValidator<AlertThresholdRequest>
|
||||
{
|
||||
public AlertThresholdRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.ObservationCode).NotEmpty().MaximumLength(50);
|
||||
RuleFor(x => x.DisplayName).NotEmpty().MaximumLength(200);
|
||||
RuleFor(x => x.Unit).NotEmpty().MaximumLength(20);
|
||||
|
||||
// Threshold ordering: CriticalLow < WarningLow < WarningHigh < CriticalHigh
|
||||
RuleFor(x => x)
|
||||
.Must(x => !x.CriticalLow.HasValue || !x.WarningLow.HasValue || x.CriticalLow < x.WarningLow)
|
||||
.WithMessage("CriticalLow must be less than WarningLow.");
|
||||
RuleFor(x => x)
|
||||
.Must(x => !x.WarningLow.HasValue || !x.WarningHigh.HasValue || x.WarningLow < x.WarningHigh)
|
||||
.WithMessage("WarningLow must be less than WarningHigh.");
|
||||
RuleFor(x => x)
|
||||
.Must(x => !x.WarningHigh.HasValue || !x.CriticalHigh.HasValue || x.WarningHigh < x.CriticalHigh)
|
||||
.WithMessage("WarningHigh must be less than CriticalHigh.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user