I want to have an optional validation. I'm using skip_if option when declaring property on a form. In the validation block I'm making it optional inside params so if the property is not passed to the validation, it would still validate successfully.
I'm expecting skipped property not to be passed to the validation at all. When using Dry::Validation::Contract and hash without a key is passed for the call it works as expected and validation passes. In Reform it's broken.
Actual behavior
Property key is still present and passed to validation with the value from validate() invocation despite the fact that property is declared with skip_if option.
Complete Description of Issue
I want to have an optional validation. I'm using
skip_if
option when declaringproperty
on a form. In thevalidation
block I'm making itoptional
insideparams
so if the property is not passed to the validation, it would still validate successfully.Steps to reproduce
Branch in my project: https://github.com/AndKiel/tournaments-api/tree/55eaf06f5e45e3969b0bc2720306d91e64aea6a3
Relevant files:
Test run focused on the form spec and contract spec (it still has focus on the form spec from the other issue): https://github.com/AndKiel/tournaments-api/pull/29/checks?check_run_id=735646841
Expected behavior
I'm expecting skipped property not to be passed to the validation at all. When using
Dry::Validation::Contract
and hash without a key is passed for thecall
it works as expected and validation passes. InReform
it's broken.Actual behavior
Property key is still present and passed to validation with the value from
validate()
invocation despite the fact thatproperty
is declared withskip_if
option.System configuration
Reform version: v2.3.1 (latest) dry-validation version: v1.5 (latest)