-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
RequiredWith #75
Comments
Unfortunately, the title doesn't say it all. Required with what? Another field? A specific value? Please elaborate. A specific use-case would be appreciated. |
Dummy example: If i have field "type" with rule "in" allowing only 1 and 2. I need another field to be required only if "type" field is 2. We can see those examples in popular frameworks like laravel and symphony. |
@DinkoMiletic probably means something like this: protected function validateRequiredWith($field, $value, array $params) {
list($match, $child) = $params;
if ($value == $match) {
return array_key_exists($child, $this->_fields) && $this->validateRequired($child, $this->_fields[$child]);
}
return true;
} When $v = new Validator($post);
$v->rule('requiredWith', 'type', '2', 'second-field);
It'd be useful if you have a form field with multiple possible values (maybe a set of checkboxes), one of which requires extra information (maybe a text field has to be filled out if one of the checkboxes is selected). The rest of the logic gets a little hinkey (e.g. |
#267 should take care of this |
Title says it all.
How would you implement this?
The text was updated successfully, but these errors were encountered: