2021-11-20 13:52:28 +01:00
|
|
|
using FluentValidation;
|
|
|
|
|
|
|
|
|
|
namespace zero.Identity;
|
|
|
|
|
|
2021-11-23 22:56:22 +01:00
|
|
|
public class BackofficeUserValidator : ZeroValidator<ZeroUser>
|
2021-11-20 13:52:28 +01:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|