How is a TypedData value validated?
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.