-
Notifications
You must be signed in to change notification settings - Fork 341
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
Allow customization of required rules #345
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was trying to implement a
required_with
/optional_with
custom validator, that would make a field required if another field is present or optional if another field is present.I got blocked by the fact that the only rules that always run even when the field is not set are 'required' and 'required_file' (hard-coded inside
GUMP::field_has_required_rules
).My first try was to override this method, but it's private...:(
My proposal is to give the consumer of the library the option to define which validators should be tagged as "required" (in the sense that they will run even if the field is not present).
I see two solutions for that:
$require_type_of_rules
insideGUMP::field_has_required_rules
to a class property or const (that can be overridden on consumer class);required
to always run (even if the field is not present).My vote is for the first option...
I'll place a PR with the change...
Ps.: Those validators could be included by default in the library since they're super useful. Please tell me if it's interesting, then I can place a PR for that.
Thanks.
The text was updated successfully, but these errors were encountered: