Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule 'requiredWith ' chaining bug #304

Open
golee opened this issue Feb 5, 2020 · 0 comments
Open

Rule 'requiredWith ' chaining bug #304

golee opened this issue Feb 5, 2020 · 0 comments

Comments

@golee
Copy link

golee commented Feb 5, 2020

requiredWith rule is not work right with rule chaining.

Check out the following example plz.

Example code

$data = [
  'name' => null,
  'price' => null
];

$rules= [
  'requiredWith' => [
    ['price', 'name']
  ],
  'integer' => ['price']
];

$v = new \Valitron\Validator($data);
$v->rules($rules);
echo $v->validate() ? "passed\n" : "failed\n";
print_r($v->errors());

Expected result

passed

Since name field value is null, price field is not required. so the validation should be passed.

Execution result

failed
Array
(
   [price] => Array
        (
            [0] => Price must be an integer
        )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant