thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

The validation was not working #5277

Closed xx10n31y closed 3 years ago

xx10n31y commented 3 years ago

Version information

Description

The validation use max validator but that was not working 1

Steps To Reproduce

Steps to reproduce the behavior:

  1. Setting the validations use the Bread
  2. Go on the relative create/update page
  3. The rank column is a signed tinyint in MySQL, and max is 127
  4. Input 256 to the rank form, then throw a exception, so the validation is not working

Expected behavior

The max validator should get back the error message but that just throw a exception

Screenshots

1

2

MrCrayon commented 3 years ago

Validation is managed by Laravel. As you are writing it validator has no way to know if you want to apply max rule as a string or number so it's applying it as a string counting characters.

You need to add integer or numeric to force the rule as number.

xx10n31y commented 3 years ago

Validation is managed by Laravel. As you are writing it validator has no way to know if you want to apply max rule as a string or number so it's applying it as a string counting characters.

You need to add integer or numeric to force the rule as number.

Thanks for your responded. I added an integer into the rule, but also not working. So only to use the max attribute.

{
    "validation": {
        "rule": "required|integer|min:0|max:200",
        "messages": {
            "required": "This :attribute field is a must.",
            "max": "This :attribute field maximum :max."
        }
    },
    "max": 100
}
Loukili-Rachid commented 2 years ago

Doing an inline validation will work properly Ex

{
    "validation": {
        "rule": "required|between:3,255|string"
    }
}
github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.