-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Custom rule not used unless field is required #251
Comments
I have experienced the exact same issue. I tried to write a 'present' rule where the field just needs to be preset in the input regardless of emptiness. Come to find out that the input index needs to be there for the rule to be ran however for some reason this works with the 'required' rule. You would think the functionality would be there to do so. |
From the readme: $v->rule('required', 'field_name', true); Having the extra parameter set to "true", the rule will only check if the key is present in the data array :) |
@willemwollebrants Thank you. Yes, I saw this but the main issue is unsolved. Can you please reopen the issue. The main issue is that custom rules are not applied unless the input filed is there. |
I think that using the required rule with the extra parameter does what you want for a "present" rule: it checks if the field is set in the input and it can be empty. Can you show me a piece of code that has the problem? |
Experience the same issue. |
I got the same issue. In my case, I want to make a custom rule |
how can i solve this. fields: foo, bar, baz, xyz foo and bar are boolean, bar and xyz numeric or null. i need to check, if foo is true then bar cannot be null or less than 0 |
I have two custom validation rules:
`
Validator::addRule('requiredIfUK', function($field, $value, array $params, array $fields) {
`
countryIsSet is applied but requiredIfUK is not. Perhaps because postcode is not in the required list?
The text was updated successfully, but these errors were encountered: