Skip to content
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

[11.x] Minor Feature a Prohibited If Declined and Prohibited If Accepted validation rules #54439

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from

Conversation

osama-98
Copy link

@osama-98 osama-98 commented Feb 2, 2025

Adding a new simple validation rules that are useful for prohibiting attributes if other attribute's value is declined or accepted, in many cases I was setting the exact value to prohibit another attribute and in most cases it has a workaround to achieve the needed validation, please see the below example to understand this change:

Before: for prohibited_if_declined

"free_delivery_fees" => "bail|required",

// this rule only covers the "false" exact value
"delivery_fees" => "prohibited_if:free_delivery_fees,false|numeric|min:1|max:9999",

// this rule only covers the "0" exact value
"delivery_fees" => "prohibited_if:free_delivery_fees,0|numeric|min:1|max:9999",

// And more for all falsy values

After: for prohibited_if_declined

"free_delivery_fees" => "bail|required",
"delivery_fees" => "prohibited_if_declined:free_delivery_fees|numeric|min:1|max:9999",

Before: for prohibited_if_accepted

"discount_disabled" => "bail|required",

// this rule only covers the "true" exact value
"discount" => "prohibited_if:discount_disabled,true|numeric|min:1|max:9999",

// this rule only covers the "1" exact value
"discount" => "prohibited_if:discount_disabled,1|numeric|min:1|max:9999",

// And more for all truthy values

After: for prohibited_if_accepted

"discount_disabled" => "bail|required",
"discount" => "prohibited_if_accepted:discount_disabled|numeric|min:1|max:9999",

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.

1 participant