2026-02-08 18:00:24 +01:00
|
|
|
using FluentValidation;
|
|
|
|
|
using IdentityShroud.Core.Messages.Realm;
|
|
|
|
|
|
2026-02-20 17:35:38 +01:00
|
|
|
namespace IdentityShroud.Api;
|
2026-02-08 18:00:24 +01:00
|
|
|
|
|
|
|
|
public class RealmCreateRequestValidator : AbstractValidator<RealmCreateRequest>
|
|
|
|
|
{
|
|
|
|
|
private const string SlugPattern = @"^(?=.{1,40}$)[a-z0-9]+(?:-[a-z0-9]+)*$";
|
|
|
|
|
|
|
|
|
|
public RealmCreateRequestValidator()
|
|
|
|
|
{
|
|
|
|
|
RuleFor(x => x.Id)
|
|
|
|
|
.NotEqual(Guid.Empty).When(x => x.Id.HasValue);
|
|
|
|
|
RuleFor(x => x.Slug)
|
|
|
|
|
.Matches(SlugPattern).Unless(x => x.Slug is null);
|
|
|
|
|
RuleFor(x => x.Name)
|
|
|
|
|
.NotNull().Length(1, 255);
|
|
|
|
|
}
|
|
|
|
|
}
|