Files
mixtape/zero.Core/Validation/BackofficeUserValidator.cs
T
2021-05-04 17:23:52 +02:00

24 lines
593 B
C#

using FluentValidation;
using zero.Core.Entities;
using zero.Core.Extensions;
namespace zero.Core.Validation
{
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);
}
}
}
}