You are here

public function CountryItem::getConstraints in Address 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/CountryItem.php, line 77

Class

CountryItem
Plugin implementation of the 'address_country' field type.

Namespace

Drupal\address\Plugin\Field\FieldType

Code

public function getConstraints() {
  $constraints = parent::getConstraints();
  $constraint_manager = $this
    ->getTypedDataManager()
    ->getValidationConstraintManager();
  $constraints[] = $constraint_manager
    ->create('ComplexData', [
    'value' => [
      'Country' => [
        'availableCountries' => $this
          ->getAvailableCountries(),
      ],
    ],
  ]);
  return $constraints;
}