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] Add case sensitive replacements in validation messages #52241

Closed
wants to merge 1 commit into from

Conversation

fabio-ivona
Copy link
Contributor

@fabio-ivona fabio-ivona commented Jul 23, 2024

premise

Until now, when a validation message is generated after a validation failure, just the :attribute replacement is case-sensitive:

// lang/en/validation.php
<?php
return [
    //..
    'required_with' => 'The :Attribute field is required when :value is present.', // or :ATTRIBUTE for uppercase
    //..
];

results in: The Email field is required when foo is present. (or EMAIL, if :ATTRIBUTE was used)

description

this pull request implements the same behavior also for other replacements in messages for:

  • present_if
  • present_unless
  • present_with (along with present_with_all)
  • required_with (along with required_with_all, required_without and required_without_all)
  • required_if
  • required_if_accepted
  • required_if_declined
  • required_unless
  • prohibited_if
  • prohibited_unless
  • prohibits

this will allow case-sensitive replacements like this one:

// lang/en/validation.php
<?php
return [
    //..
    'required_with' => 'The :Attribute field is required when :Value is present.', // or :ATTRIBUTE for uppercase
    //..
];

will now result in: The Email field is required when Foo is present. (or EMAIL/FOO, if :ATTRIBUTE/:VALUE was used)

@fabio-ivona fabio-ivona force-pushed the 11.x branch 2 times, most recently from 55a3f71 to 6074bed Compare July 23, 2024 15:21
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

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