public function PriceItem::getConstraints in Price 3.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldType/PriceItem.php \Drupal\price\Plugin\Field\FieldType\PriceItem::getConstraints()
- 2.0.x src/Plugin/Field/FieldType/PriceItem.php \Drupal\price\Plugin\Field\FieldType\PriceItem::getConstraints()
- 2.x src/Plugin/Field/FieldType/PriceItem.php \Drupal\price\Plugin\Field\FieldType\PriceItem::getConstraints()
- 3.0.x src/Plugin/Field/FieldType/PriceItem.php \Drupal\price\Plugin\Field\FieldType\PriceItem::getConstraints()
Gets a list of validation constraints.
Return value
array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.
Overrides TypedData::getConstraints
1 call to PriceItem::getConstraints()
- PriceModifiedItem::getConstraints in src/
Plugin/ Field/ FieldType/ PriceModifiedItem.php - Gets a list of validation constraints.
1 method overrides PriceItem::getConstraints()
- PriceModifiedItem::getConstraints in src/
Plugin/ Field/ FieldType/ PriceModifiedItem.php - Gets a list of validation constraints.
File
- src/
Plugin/ Field/ FieldType/ PriceItem.php, line 101
Class
- PriceItem
- Plugin implementation of the 'price' field type.
Namespace
Drupal\price\Plugin\Field\FieldTypeCode
public function getConstraints() {
$manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $manager
->create('ComplexData', [
'number' => [
'Regex' => [
'pattern' => '/^[+-]?((\\d+(\\.\\d*)?)|(\\.\\d+))$/i',
],
],
]);
$available_currencies = $this
->getSetting('available_currencies');
$constraints[] = $manager
->create('Currency', [
'availableCurrencies' => $available_currencies,
]);
return $constraints;
}