I have various functions/methods that programmatically create entities (nodes). I just noticed that invalid data has been getting stored in the db though these functions (invalid in that it doesn't meet the rules defined for that field).
How do I validate the data before $entity->save()?
I have seen documentation saying that I simply need to do $entity->validate() and then count if there are any errors; but I have marked a few fields as required and then left them empty in my API function and $entity->validate()->count() is always 0.
What am I missing?