How to add constrain validation on entity_create
Entities aren't validated automatically when saved via the API. (I'd be interested in knowing more about why not.) See the validation API docs for examples of validating a field and a whole entity:

$violations = $entity-&gt;field_text-&gt;validate(); // single field
$violations = $entity-&gt;validate();             // whole entity

if ($violations-&gt;count() &gt; 0) {
  // Validation failed.
}


To find all possible constraints, look for anything extending (possibly indirectly) \Symfony\Component\Validator\Constraint.