Hello,
I'm currently facing an issue with conditional validation in Laravel when using the mimes rule. Here's the problem:
I have two fields in my form: company_tin_number and company_tin_certificate. The validation rules for these fields should vary based on the company_type selected by the user.
For company_tin_number, it should be required when company_type is "partnership," "limited," or "others," and it should have a maximum length of 50 characters. This part is working correctly.
However, for company_tin_certificate, I want it to be required and validated as a PDF file (with a maximum size of 7000 KB) only when the company_type matches the specified values. The problem I'm encountering is that the mimes rule is being triggered even when company_type doesn't match the conditions, resulting in an error message that says, "company_tin_certificate must be a file of type: pdf."
Here's my current validation rule for company_tin_certificate:
'company_tin_certificate' => 'required_if:company_type,partnership,limited,others|mimes:pdf|max:7000',
Is there a way to conditionally apply the mimes rule based on the company_type? Any insights or suggestions on how to resolve this issue would be greatly appreciated.
Thank you!