public EditCurrencyCommandValidator( IExistsInCurrentContextValidatorProvider exists, IUniqueInCurrentContextValidatorProvider beUnique) { RuleFor(x => x.Id) .NotNull() .GreaterThan(0) .Must(exists.In <Currency>()); RuleFor(x => x.Code) .NotEmpty() .MaximumLength(3) .Must(beUnique.In <Currency>() .WhereNot <EditCurrencyCommand>(cmd => x => x.Id != cmd.Id && x.Code == cmd.Code)); RuleFor(x => x.Name) .NotEmpty() .MaximumLength(255); RuleFor(x => x.Symbol) .NotEmpty() .MaximumLength(12); RuleFor(x => x.DecimalPlaces) .NotNull() .LessThanOrEqualTo((ushort)18); }
public DeleteAccountCommandValidator(IExistsInCurrentContextValidatorProvider exists) { RuleFor(x => x.Id) .NotNull() .GreaterThan(0) .Must(exists.In <Account>()); }
public GetCategoryQueryValidator(IExistsInCurrentContextValidatorProvider exists) { RuleFor(x => x.Id) .NotNull() .GreaterThan(0) .Must(exists.In <Category>()); }
public EditAccountCommandValidator( IExistsInCurrentContextValidatorProvider exists, IUniqueInCurrentContextValidatorProvider beUnique) { RuleFor(x => x.Id) .NotNull() .GreaterThan(0) .Must(exists.In <Account>()); RuleFor(x => x.Name) .NotEmpty() .MaximumLength(1000) .Must(beUnique.In <Account>() .WhereNot <EditAccountCommand>( x => x.Id, (instance, cmd) => x => x.Id != cmd.Id && x.Name == cmd.Name && x.Type == instance.Type)); RuleFor(x => x.Description) .MaximumLength(2000); RuleFor(x => x.CurrencyId) .NotEmpty() .GreaterThan(0) .Must(exists.In <Currency>()); }
public EditTagCommandValidator( IExistsInCurrentContextValidatorProvider exists, IUniqueInCurrentContextValidatorProvider beUnique) { RuleFor(x => x.Id) .NotNull() .GreaterThan(0) .Must(exists.In <Currency>()); RuleFor(x => x.Name) .NotEmpty() .MaximumLength(1000) .Must(beUnique.In <Tag>() .WhereNot <EditTagCommand>(cmd => x => x.Name == cmd.Name)); RuleFor(x => x.Description) .MaximumLength(2000); }
public CreateAccountCommandValidator( IExistsInCurrentContextValidatorProvider exists, IUniqueInCurrentContextValidatorProvider beUnique) { RuleFor(x => x.Name) .NotEmpty() .MaximumLength(1000) .Must(beUnique.In<Account>() .WhereNot<CreateAccountCommand>(cmd => x => x.Name == cmd.Name && x.Type == cmd.Type)); RuleFor(x => x.Description) .MaximumLength(2000); RuleFor(x => x.Type).NotEmpty(); RuleFor(x => x.CurrencyId) .NotEmpty() .GreaterThan(0) .Must(exists.In<Currency>()); }