public function MeasurementItem::getConstraints in Physical Fields 8
Gets a list of validation constraints.
Return value
array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.
Overrides TypedData::getConstraints
File
- src/
Plugin/ Field/ FieldType/ MeasurementItem.php, line 71
Class
- MeasurementItem
- Plugin implementation of the 'physical_measurement' field type.
Namespace
Drupal\physical\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraint_manager = $this
->getTypedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager
->create('ComplexData', [
'number' => [
'Regex' => [
'pattern' => '/^[+-]?((\\d+(\\.\\d*)?)|(\\.\\d+))$/i',
],
],
]);
return $constraints;
}