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

Bypass validation with required_if #78

Open
lannodev opened this issue Oct 25, 2024 · 0 comments
Open

Bypass validation with required_if #78

lannodev opened this issue Oct 25, 2024 · 0 comments

Comments

@lannodev
Copy link

I'm using validation for CNPJ, but if my condition includes required_if, CNPJ validation is always triggered, regardless of whether the condition is true or false.

$request->validate([
      'product' => 'required|max:15',
      'serie' => 'required|max:20',
      'reseller' => 'required|in:true,false',
      'purchase_date' => 'required|date_format:Y-m-d',
      'reseller_name' => 'required_if:reseller,true|max:50',
      'reseller_cnpj' => 'required_if:reseller,true|cnpj', // always triggered
      'invoice_code' => 'required|max:20',
      'invoice_key' => 'required|max:44',
  ]);
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

No branches or pull requests

1 participant