hook_field_validate() never called on custom entity

Submitted by Too on Tue, 05/04/2021 - 15:56

When I was creating own custom entity with custom field type in it I saw that myfield_field_validate() implementation of hook_field_validate() was never called. Documentation about this hook tells nothig about additional line of code for it to work...
<!--break-->
The point is on your CUSTOM ENTITY type you need to call <code><b>entity_form_field_validate()</b></code> in myentitymodule_form_validate() main entity admin form validation. Only this line of code will run all custom fields validations. And very sad that neither on the custom entity creation turtorial nor in hook_field_validate() documentation. So if you don't have that line if your custom entity form validation - you have no validation of 'list','number',... field types.