-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: "integer" validation rule 500 error #6489
Comments
@ddevsr you missed the rule |
@iRedds Okay i updated |
@shishamo If you validate non string data, I recommend you use Strict Rules. |
You want strict typed validation, so this is not a bug. You must use Strict Rules. |
@kenjis I set the strict rules and i have
and i have an error as below
|
If i set the strict rules, does it mean than i cannot use the available rules in CI? https://codeigniter4.github.io/CodeIgniter4/libraries/validation.html#available-rules |
No, all rules should be avaliable, and if not it is a bug.
It is a bug. |
@shishamo Should |
Sorry i didn't get the question well but In case of the client as below
Validation is true
Validation is false Accepts only strict integer type greater or equal to 1 |
Thank you for your opinion. Why
|
I need to be sure in the process of my api than the parameter in an integer Maybe better to create a custom rule for that validation then? |
I have a question. Is it ok if In that case, you can set the rule |
the problem in that case is if the client send
there is no problem but if he send
a 500 error occurs now if the value of integerGreaterOrEqualTo1 is automatically cast in string numeric when validate i can handle it and cast it in int after but i looks a bit strange i think? because php is_int function check the strict type and validate only integer |
It is just a bug. |
What is the consensus here? Is this a bug or not? If not, then we can close this and the related PR. |
I think this is a bug, because Errors should not happen in validations. If a user send unexpected value, an error will occur in the validation. However, the default Validation rule originally cannot properly validate JSON data. |
Since v4.3.0, Strict Validation Rules are used by default. |
Does anyone want to fix this? Why don't we make the traditional rules deprecated? |
I switched to using strict rules. There are no problems yet |
Closed by #8078 |
PHP Version
8.1
CodeIgniter4 Version
4.2.5
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
The validation rule "integer" fail as 500 error as below
That validation allows string numeric (not integer) as well
Steps to Reproduce
Validation rule used
Data to validate
Expected Output
Validation fail and return 400 if the value is not an integer
Anything else?
No response
The text was updated successfully, but these errors were encountered: