Closed GoldraK closed 6 years ago
I'm not an expert in the Respect\Validation library, but I think to have conditional rules based on another field's, we must pass the complete data to validate.
The validateArray method passes a single value for each rule, unlike your example where you pass the whole $values
array. So, when we validate the field other_use_building
we pass only the value for this field. Hence, the error Key use_building must be present
.
Try replacing this line
$rule->setName($field)->assert($this->getValue($values, $field));
with
$rule->setName($field)->assert($values);
I haven't tested this change, it might work or you may need to define your logic for you specific use case.
Thanks, go to see
I am using your development to make a new API.
But I have encountered a problem with validateArray and can not use the when option
I have the following data array:
The validation has to check that when use_building is 8 the other_use_building is not empty.
If I perform the validation in a file for tests, the following validation works correctly:
But when I enter it in the validateArray system
tells me what error when he had to see given true