Problem/Motivation
In a review of #2230909: Simple decimals fail to pass validation it was discovered that \Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::getConstraints does not contain any constraint aimed at scale and precision of decimals.
This would make it possible for a value that exceeds the precision and/or scale of a field to be submitted successfully via API and probably trigger a SQL error instead of a constraint violation or worse, no error at all.
Steps to reproduce
Proposed resolution
Move/copy the precision/scale validation from \Drupal\Core\Render\Element\Number::validateNumber to a constraint on the Decimal entity.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3300348
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
darvanenComment #8
berliner commentedI have started with what I think are the necessary tests to cover entity validation with regards to precision and scale of decimal fields. I'll try to get to the implementation in the next days. If anyone else wants to go ahead, please do.