Files
Heimdall/src/Heimdall.Application/Validators/CreateAppSettingValidator.cs
T
Arnaud Dartois dce668c012 fix(settings): accepte les aliases de type boolean/number dans les validateurs
L'IHM propose boolean/number mais les validateurs n'acceptaient que
bool/int/double → impossible de créer ou modifier un paramètre depuis
l'écran Configuration (400).
2026-08-10 20:17:35 +02:00

19 lines
870 B
C#

using FluentValidation;
using Heimdall.Application.DTOs;
namespace Heimdall.Application.Validators;
public class CreateAppSettingValidator : AbstractValidator<CreateAppSettingRequest>
{
public CreateAppSettingValidator()
{
RuleFor(x => x.Key).NotEmpty().MaximumLength(200)
.Matches(@"^[a-z0-9][a-z0-9._-]*[a-z0-9]$")
.WithMessage("Key must start and end with a lowercase alphanumeric character, and contain only lowercase letters, digits, dots, hyphens, or underscores");
RuleFor(x => x.Value).NotNull();
RuleFor(x => x.Category).NotEmpty().MaximumLength(100);
RuleFor(x => x.ValueType).Must(t => t is "string" or "int" or "integer" or "bool" or "boolean" or "double" or "number" or "select" or "dropdown")
.WithMessage("ValueType must be one of: string, int, bool, double, select");
}
}