Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public DeleteAccountCommandValidator(IExistsInCurrentContextValidatorProvider exists)
 {
     RuleFor(x => x.Id)
     .NotNull()
     .GreaterThan(0)
     .Must(exists.In <Account>());
 }
Ejemplo n.º 3
0
 public GetCategoryQueryValidator(IExistsInCurrentContextValidatorProvider exists)
 {
     RuleFor(x => x.Id)
     .NotNull()
     .GreaterThan(0)
     .Must(exists.In <Category>());
 }
Ejemplo n.º 4
0
 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>());
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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>());
 }