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

Value attribute not getting replaced properly for gt/gte/lt/lte validation rules #25481

Closed
martinbean opened this issue Sep 6, 2018 · 3 comments

Comments

@martinbean
Copy link
Contributor

  • Laravel Version: 5.7.0 (and below)
  • PHP Version: 7.1.14
  • Database Driver & Version: N/A

Description:

The :value attribute isn’t being replaced properly for gt/gte/lt/lte validation rules. When I specify a value, the error message always comes out as:

The quantity must be greater than or equal 0.

Looking under the hood, it seems the replacer method is validating the size rather than the integer value of the parameter.

Steps To Reproduce:

Create a brand new application; placed this in a route:

$validator = Validator::make(
    ['quantity' => 5],
    ['quantity' => 'gte:10']
);

Validation fails (as expected), but the error message is:

The quantity must be greater than or equal 0.

I expect:

The quantity must be greater than or equal 10.

@staudenmeir
Copy link
Contributor

@Alymosul Can you explain why you used

return str_replace(':value', $this->getSize($parameters[0], $this->getValue($parameters[0])), $message);

instead of just

return str_replace(':value', $parameters[0], $message);

in #24135?

@Alymosul
Copy link
Contributor

Alymosul commented Sep 7, 2018

@martinbean Yes I confirm that this is a bug, I'll submit a PR to fix it. Thank you for pointing this out.

@staudenmeir The purpose of these rules at first was to compare two attributes(input fields) against each other, then I extended the functionality to include comparing against values but it seems i forgot to check if you passed an attribute or a value in the ReplaceAttributes trait methods.

@staudenmeir
Copy link
Contributor

Please close the issue.

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

4 participants