By graber on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.2.x
Introduced in version:
10.2.0
Issue links:
Description:
A new 'decimal' data type has been added that can now be used for decimal data instead of string type.
It also contains data type validation.
Creating decimal field properties (see Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::propertyDefinitions()) should now use the new decimal data type instead of string with custom validation constraints as that's already covered in the data type.
Before:
$properties['value'] = DataDefinition::create('string')
->setLabel(new TranslatableMarkup('Decimal value'))
...
Plus additional validation constraints to check if the value is actually numeric.
After:
$properties['value'] = DataDefinition::create('decimal')
->setLabel(new TranslatableMarkup('Decimal value'))
...
With no additional validation constraints as the type itself contains validation.
Impacts:
Module developers
Comments
decimal precision limitation
One should mention that it underlies the float max precision of php which is 15.