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
Specifying Cake\Validation\Validator::decimal() $places parameter causes validation to fail #17459
Comments
As can be seen in the following screenshot the So for me ( Therefore this returns false since it changes My main question now for my fellow core devs is: shouldn't that validation method be called Maybe I misunderstand something here but no matter which locale I have set in my browser/OS a input number with a |
@maurobrandoni1 which locale is set in your app? Meaning, what do you have in your |
Yeah, the locale part comes from the time where normal text fields are being used. That said: E.g. English vs German: Wouldnt it make more sense to normalize this to the new
when dealing with the input from user? And back to localized string on output anywhere it is used, of course. Note: Also PHP 7.4+ |
The support for input type number has been great for quite some time. We also default to it in the FormHelper so we should adapt this as well imho. Input numbers are submitted as string without a thousand's separator anyway as far as I have tested it. So there is no thousands place to replace here. I'd still keep the regex part here so it still supports larger numbers (in both directions) than float can support as well. In the end I think we just have to rip out the NumberFormatter parts and we should be fine. |
@maurobrandoni1
in your code? As that seems to make it work for me. |
I just tried it with the FloatType (since my db columns are of type
inside my bootstrap.php but this problem still exists for me |
It could be that float is not a valid type for a decimal check (since float doesnt have the precision/scale by nature). |
My locale is 'es' Adding this piece of code to my bootstrap.php doesn't make any difference:
Foo->getSchema():
|
I am not too familiar with ES, but it seems to want a comma as decimal separator: es_MX however again: https://sandbox.dereuromark.de/sandbox/decimal-examples/validation/es_MX?value=1234.56 |
I agree, similar to I too would except Sadly due to backwards compatibility issues we can't change it even in 5.x :( |
yes, but we can at least document it and make it clear how it currently behaves |
This issue is stale because it has been open for 120 days with no activity. Remove the |
Description
How to reproduce the problem:
FooTable.php:
FooController.php:
According to @LordSimal
CakePHP Version
4.4.17
PHP Version
No response
The text was updated successfully, but these errors were encountered: