24 lines
592 B
C#
24 lines
592 B
C#
using FluentValidation;
|
|
using zero.Core.Entities;
|
|
using zero.Core.Extensions;
|
|
|
|
namespace zero.Core.Validation
|
|
{
|
|
public class BackofficeUserValidator : AbstractValidator<IUser>
|
|
{
|
|
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.Roles).NotEmpty();
|
|
|
|
if (isCreate)
|
|
{
|
|
RuleFor(x => x.IsSuper).Equals(false);
|
|
}
|
|
}
|
|
}
|
|
}
|