Files
mixtape/zero.Core/Identity/Validation/BackofficeUserValidator.cs
T
2021-11-20 13:52:28 +01:00

21 lines
500 B
C#

using FluentValidation;
namespace zero.Identity;
public class BackofficeUserValidator : ZeroValidator<BackofficeUser>
{
public BackofficeUserValidator(bool isCreate = false)
{
RuleFor(x => x.Name).Length(2, 80);
RuleFor(x => x.Email).NotEmpty().Email().MaximumLength(120);
RuleFor(x => x.PasswordHash).NotEmpty();
RuleFor(x => x.LanguageId).NotEmpty();
RuleFor(x => x.RoleIds).NotEmpty();
if (isCreate)
{
RuleFor(x => x.IsSuper).Equals(false);
}
}
}