Users should be validated before being created.
Use the EntityResourceValidationTrait before performing a save.
EntityResourceValidationTrait
Active
3.1
Code