How to properly check in entity form validation if field is empty? I have a content type "A" (Node entity type).
In it's node form (new/edit) I need to check if some fields are empty or not (which are not required in general).
My first intention was to use FormState "getValue", "isValueEmpty", "hasValue" functions, but I can't figure out how to easily solve this problem:


Text fields has value: array("value"=&gt; "") if they are empty, and it's not considered empty by the functions above (so I can't use them)
I could check by myself for isset($field['value']), but there are also file fields and entity reference fields which has a whole different "value" structure.


So what would be a clean way to achieve this?
I think I found what I was looking for, ContentEntityForm does it like this:

/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this-&gt;buildEntity($form, $form_state);
$violations = $entity-&gt;validate();


All I have to do is building the entity, after that I have to just check the right field, which has already the ability to tell per fields if they are empty or not. (since each field is knowing it's type and also how to check if there is a value or not)