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.
Comments
Comment #2
darvanen