2020-03-25 00:47:14 +01:00
|
|
|
using FluentValidation;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Extensions;
|
|
|
|
|
|
|
|
|
|
namespace zero.Core.Validation
|
|
|
|
|
{
|
2020-04-03 18:03:36 +02:00
|
|
|
public class BackofficeUserValidator : AbstractValidator<IUser>
|
2020-03-25 00:47:14 +01:00
|
|
|
{
|
|
|
|
|
public BackofficeUserValidator(bool isCreate = false)
|
|
|
|
|
{
|
|
|
|
|
RuleFor(x => x.Name).NotEmpty();
|
|
|
|
|
RuleFor(x => x.Email).Email();
|
|
|
|
|
RuleFor(x => x.PasswordHash).NotEmpty();
|
|
|
|
|
RuleFor(x => x.LanguageId).NotEmpty(); // TODO only allow available languages
|
|
|
|
|
RuleFor(x => x.RoleIds).NotEmpty();
|
|
|
|
|
|
|
|
|
|
if (isCreate)
|
|
|
|
|
{
|
|
|
|
|
RuleFor(x => x.IsSuper).Equals(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|