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

[5.5] add ability to show input value in validation error messages #21175

Merged
merged 7 commits into from
Sep 13, 2017
Merged

[5.5] add ability to show input value in validation error messages #21175

merged 7 commits into from
Sep 13, 2017

Conversation

themsaid
Copy link
Member

validator(['email' => 'Mohamed'], ['email' => 'email'])->validate();

With this PR, you can have the error message of the email rule as :actual_value is not a valid email, and the error output will become Mohamed is not a valid email.

@m1guelpf
Copy link
Contributor

@themsaid This can lead to XSS errors when showing errors using something like Sweetalert...

@themsaid
Copy link
Member Author

It's not used by default in the framework, it's optional so you can use it if you want and apply xss protection on the form submission before handing it to the validator.

@msonowal
Copy link
Contributor

@themsaid finally it is fixed I have raised this bug earlier in 5.4 but I am unable to find it but will be good to see if you can send it to 5.4 as well as it is more of a patched.
Thanks for your continuous contribution to the laravel community.

@taylorotwell
Copy link
Member

I would call the place-holder :input.

@themsaid
Copy link
Member Author

@taylorotwell renamed to :input

@taylorotwell taylorotwell merged commit c9d0f0c into laravel:5.5 Sep 13, 2017
@leyluj
Copy link

leyluj commented Sep 14, 2017

I suggested this on TWITTER 😃 !, is it available on 5.4?

@themsaid
Copy link
Member Author

@leyluj nope, 5.5 only, 5.4 isn't maintained anymore. The upgrade is really easy you should do it :)

@leyluj
Copy link

leyluj commented Sep 14, 2017

Noted let me try.

Thanks

@leyluj
Copy link

leyluj commented Sep 14, 2017

Done, i have upgraded but :input is not working.

What might be the problem?

@themsaid
Copy link
Member Author

@leyluj will be released on next patch.

@@ -266,6 +268,24 @@ protected function replaceAttributePlaceholder($message, $value)
}

/**
* Replace the :actual_value placeholder in the given message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:input here:)

@franzliedke
Copy link
Contributor

you can use it if you want and apply xss protection on the form submission before handing it to the validator.

@themsaid Will this be made clear in the documentation?

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.

None yet

7 participants