1

I have a model with amount parameter that have to be greater than zero. My form asks a user for a number to subtract from the model's amount. How do I validate my model after subtracting the number from amount?

Example: right now the amount is 50. User input is 51. 50-51 = -1 which is less than 0. Validation should fail.

Right now my operation looks like this, but it validates only user input, not the final model:

step :model!
step :new_amount!
step Contract::Build()
step Contract::Validate()
step Contract::Persist()
Nadiya
  • 1,421
  • 4
  • 19
  • 34

1 Answers1

0

I used deserializer inside the contract to subtract value first.

Nadiya
  • 1,421
  • 4
  • 19
  • 34