You are here

public function NifItem::getConstraints in Field NIF 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/NifItem.php, line 76

Class

NifItem
Plugin implementation of the 'nif' field type.

Namespace

Drupal\field_nif\Plugin\Field\FieldType

Code

public function getConstraints() {
  $constraints = parent::getConstraints();
  $constraint_manager = \Drupal::typedDataManager()
    ->getValidationConstraintManager();
  $constraints[] = $constraint_manager
    ->create('ComplexData', [
    'value' => [
      'NifValue' => [
        'supportedTypes' => array_filter($this
          ->getSetting('supported_types')),
      ],
    ],
  ]);
  return $constraints;
}