2020-03-25 00:47:14 +01:00
|
|
|
using FluentValidation;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Extensions;
|
|
|
|
|
|
|
|
|
|
namespace zero.Core.Validation
|
|
|
|
|
{
|
2021-05-04 17:23:52 +02:00
|
|
|
public class BackofficeUserValidator : ZeroValidator<BackofficeUser>
|
2020-03-25 00:47:14 +01:00
|
|
|
{
|
|
|
|
|
public BackofficeUserValidator(bool isCreate = false)
|
|
|
|
|
{
|
2020-09-09 13:43:01 +02:00
|
|
|
RuleFor(x => x.Name).Length(2, 80);
|
|
|
|
|
RuleFor(x => x.Email).NotEmpty().Email().MaximumLength(120);
|
2020-03-25 00:47:14 +01:00
|
|
|
RuleFor(x => x.PasswordHash).NotEmpty();
|
2020-09-09 13:43:01 +02:00
|
|
|
RuleFor(x => x.LanguageId).NotEmpty();
|
2020-11-05 00:27:02 +01:00
|
|
|
RuleFor(x => x.RoleIds).NotEmpty();
|
2020-03-25 00:47:14 +01:00
|
|
|
|
|
|
|
|
if (isCreate)
|
|
|
|
|
{
|
|
|
|
|
RuleFor(x => x.IsSuper).Equals(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|