I built a custom field type using the Field API. In hook_field_validate
I have some logic to validate some very custom stuff, but when I tried to add a "This field is required" validation, I realized this hook runs on the from that you fill when you're adding a field to an entity. Then, I implemented hook_field_is_empty
, which I know runs when the entity saves. Problem is, even if the hook runs and the field is empty, no validation occurs (i.e. the user doesn't get the "this is required" message, and the form submits).
So, what's the right way to do a "this field is required" validation?