You are here

public function TimeType::getConstraints in Time Field For Drupal 8.x / 9.x 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldType/TimeType.php \Drupal\time_field\Plugin\Field\FieldType\TimeType::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

File

src/Plugin/Field/FieldType/TimeType.php, line 61

Class

TimeType
Plugin implementation of the 'time' field type.

Namespace

Drupal\time_field\Plugin\Field\FieldType

Code

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