Problem/Motivation
When having a a Number (decimal) with precision of 20 and scale of 10 it's impossible to submit manually entered values like 1.0 100.0 aka >= 1
It seems impossible to enter values greater equal 1.
Probably core/lib/Drupal/Component/Utility/Number.php:37 is in error?
<?php
public static function validStep($value, $step, $offset = 0.0) {
$double_value = (double) abs($value - $offset);
?>
From #4
It seems to me that validStep shouldn't be called for a decimal number as it's not supposed to be a IEEE 754 single or double precision float and that function validates for that.
If the precision/scale is set to 20/10 then the precision is higher than a double for most values and the validation fails.
I've changed the test for that in my patch.
Steps taken
- Add a Number (decimal) to http://drupal.d8/admin/structure/types/manage/article
- Set precision to 20
- Set scale to 10
- Add/edit an article
- Click the number spinner and save the node: Ok
- Type 1.001 and save the node: Decimal is not a valid number.
- Use the spinner (value is now 1.0000100001) and save the node: Decimal is not a valid number.
- Change value to 0.0000100001 and save the node: Ok
Proposed resolution
Detach decimal field from the number validation. It's not a float and has no scale. It's validation can be done exactly by ie a regex.