Open vjik opened 3 years ago
It is difficult to work with optional fields. Has two algorithm. For example, field sort optional and maybe "asc" or "desc".
sort
Strict algorithm
If data has field (even empty), then we validate him.
['sort' => 'asc'] // asc ['sort' => 'desc'] // desc ['sort' => 'up'] // error ['sort' => ''] // error [], // null
Non-strict algorithm
If data not have field or field is empty, then we believe that the value was not passed.
['sort' => 'asc'] // asc ['sort' => 'desc'] // desc ['sort' => 'up'] // error ['sort' => ''] // null [], // null
I'm created #14 with test for both algorithms. Tests pass, but implementation of models very difficult. Need find more beautiful solution.
@see https://github.com/yiisoft/validator/pull/102
It is difficult to work with optional fields. Has two algorithm. For example, field
sort
optional and maybe "asc" or "desc".Strict algorithm
If data has field (even empty), then we validate him.
Non-strict algorithm
If data not have field or field is empty, then we believe that the value was not passed.
I'm created #14 with test for both algorithms. Tests pass, but implementation of models very difficult. Need find more beautiful solution.