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

Unable to customize validation error messages from form request #262

Closed
Stichoza opened this issue Dec 26, 2024 · 2 comments
Closed

Unable to customize validation error messages from form request #262

Stichoza opened this issue Dec 26, 2024 · 2 comments

Comments

@Stichoza
Copy link

Laravel-Phone version

5.3.2

Steps to reproduce

  • Create a form request and define custom error message for phone rule in messages() method.
  • Add phone:ge rule to any field – it will display custom message in case of failed validation (correct behavior).
  • Now replace phone:ge rule with (new Phone)->country('ge').
  • Validation still works correctly, but validation.phone string will be displayed instead of custom message.

Observed vs Expected behavior

I have a Form Request where I have defined custom validation messages, including one for phone rule.

This custom validation error is displayed correctly if I add phone or phone:ge rule to field. However, untranslated validation.phone string is displayed when I add (new Phone)->country($country->code) to rules.

Translation works for both phone/phone:ge and (new Phone)->country($country->code) if I define custom error messages in global resources/lang/en/validation.php, but if i define same errors in form requests messages() method, it only works for phone and phone:ge rules, not for (new Phone)->country($country->code).

@Propaganistas
Copy link
Owner

@devfrey
Copy link

devfrey commented Jan 2, 2025

@Propaganistas Next time please don't change a class' contract on a patch release. I relied on Phone::setValidator() and Phone::passes(), which were removed/changed in 2172362

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

3 participants