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()
I used deserializer inside the contract to subtract value first.