Skip to content

Conversation

JasonTheAdams
Copy link
Member

Presently it's only possible to append validation rules and remove rules. In GiveWP we have a scenario where we want to prepend a ExcludeUnless rule to a given ruleset. Actually, we want to replace the rule if it already exists and prepend if it doesn't.

This led me to add some useful functions for prepending and replacing rules within a ValidationRuleSet:

  • prependRule
  • replaceRule — replaces a rule with a given ID at the same position in the rule set
  • replaceOrAppendRule
  • replaceOrPrependRule

The last two, of course, are just to be declarative and helpful.

@JasonTheAdams JasonTheAdams self-assigned this Mar 27, 2023
@borkweb
Copy link
Member

borkweb commented Mar 28, 2023

Other than that one comment that applies to replaceOrAppendRule and replaceOrPrependRule, this looks rad. 🍔

@JasonTheAdams JasonTheAdams merged commit 56e45ac into develop Mar 28, 2023
@JasonTheAdams JasonTheAdams deleted the feature/replace-and-prepend-methods branch March 28, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants