How is a TypedData value validated? I do not understand how the Boolean (just for example) is validated. This is my code:

$tdm = \Drupal::typedData();
$data = $tdm-&gt;create(array('type' =&gt; 'boolean'), 1000);
drush_print_r($data-&gt;validate());


The $data-&gt;validate() returns a list of ConstraintViolations, but where is the logic of these constraints, per Drupal\Core\TypedData\Plugin\DataType\Boolean does not implements getConstraints method.

Thanks
Primitive types are special case.

By default, they get the PrimitiveType validation constraint in TypedDataManager::getConstraints(). 

&lt;?php
// Auto-generate a constraint for data types implementing a primitive
// interface.
if (is_subclass_of($type_definition['class'], '\Drupal\Core\TypedData\PrimitiveInterface')) {
  $constraints[] = $validation_manager-&gt;create('PrimitiveType', array());
}
?&gt;


Validation constraints are usually provided in one of the following places:


The plugin annotation (see e.g. EntityReferenceItem)
base field/property definitions (see e.g. Node::baseFieldDefinitions(), title field)
By overriding the getConstraints() method on a typed data class.