array('min' => 5, 'max' => 10), * 'NotBlank' => array(), * ); * @endcode * Options have to be specified using another array if the constraint has more * than one or zero options. If it has exactly one option, the value should be * specified without nesting it into another array: * @code * $constraints = array( * 'EntityType' => 'node', * 'Bundle' => 'article', * ); * @endcode * * Note that the specified constraints must be compatible with the data type, * e.g. for data of type 'entity' the 'EntityType' and 'Bundle' constraints * may be specified. * * @see \Drupal\Core\Validation\ConstraintManager * * @return array[] * An array of validation constraint definitions, keyed by constraint name. * Each constraint definition can be used for instantiating * \Symfony\Component\Validator\Constraint objects. * * @see \Symfony\Component\Validator\Constraint */ public function getConstraints(); /** * Returns a validation constraint. * * See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for * details. * * @param string $constraint_name * The name of the constraint, i.e. its plugin id. * * @return array * A validation constraint definition which can be used for instantiating a * \Symfony\Component\Validator\Constraint object. * * @see \Symfony\Component\Validator\Constraint */ public function getConstraint($constraint_name); /** * Adds a validation constraint. * * See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for * details. * * @param string $constraint_name * The name of the constraint to add, i.e. its plugin id. * @param array|null $options * The constraint options as required by the constraint plugin, or NULL. * * @return static * The object itself for chaining. */ public function addConstraint($constraint_name, $options = NULL); /** * Determines whether the data value is internal. * * This can be used in a scenario when it is not desirable to expose this data * value to an external system. * * The implications of this method are left to the discretion of the caller. * For example, a module providing an HTTP API may not expose entities of * this type or a custom entity reference field settings form may reduce the * priority for entities of this type in a select list. * * @return bool * Whether the data value is internal. */ public function isInternal(); }