function DecimalItem::getConstraints
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php \Drupal\Core\Field\Plugin\Field\FieldType\DecimalItem::getConstraints()
Overrides NumericItemBase::getConstraints
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ DecimalItem.php, line 94
Class
- DecimalItem
- Defines the 'decimal' field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager->create('ComplexData', [
'value' => [
'Regex' => [
'pattern' => '/^[+-]?((\\d+(\\.\\d*)?)|(\\.\\d+))$/i',
],
],
]);
return $constraints;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.