You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Convert the local variable $require_type_of_rules inside GUMP::field_has_required_rules to a class property or const (that can be overridden on consumer class);
Change the logic to consider any validator starting with 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:
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: