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
{{ message }}
Repository navigation
Inject current database row id on custom validation rule #117
This is kind of a follow up to issue #114 which lead to the fix of the injection of the current database rows id into laravels default unique validation rule. My problem is now, that I have a custom validation rule from another package felixkiss/uniquewith-validator called unique_with. This rule basically tests if the combination of a number of columns is unique, i. e. the combination of foreign_key_1, foreign_key_2 and foreign_key_3
This leads to the exact same issue as with laravels default unique rule when validation happens on updating: Of course the combination already exists. It exists on the model itself.
Thankfully the author of the package has thought about this as well and you append a row id as the last parameter to the rule to ignore it, just like laravels unique rule does it.
My problem is just how to achieve this while using the validating trait. The only solution I could come up with until now is adding a new config parameter and a new method that does all specified rules. This would basically be a generalisation of the current injectUniqueIdentifierToRules() and a configuration for it which by default replaces laravels own rule and if someone needs it like I do in this case they can add other rules to inject it into.
Activity
dwightwatson commentedon Jan 30, 2015
Yeah, I'd definitely be open to that functionality. I'm a little swamped at the moment but happy to accept a PR in the meantime.