Field validation: hooks vs callbacks In D7 there appear to be various methods by which a module can carry out validation of a form's fields, including:


#element_validate callback
#validate callback
hook_field_validate() implementation
hook_form_validate() implementation
hook_field_attach_validate() implementation


Firstly, can anyone list the execution order of the above?

Secondly, can anyone please explain why one might choose to use a callback instead of a hook or a hook instead of a callback?
#element_validate is used to provide validation for a specific element.
#validate is used for the form, and for elements that cause the form to submit (button, image_button, submit). It provides the names of extra functions to call during the validation process.
hook_field_validate() is for validating fields (not standard form elements). This doesn't necessarily take place in the context of a form submission.
There's isn't a hook_form_validate() - by convention if a function called FORM_ID_validate() exists then it will be used as part of the above #validate array for the form. This is used to validate any part of the form, not just a specific element.
hook_field_attach_validate() runs as validation when fields are attached to an entity, it doesn't run in the context of a form (see field_attach_validate())


Not all of the above are executed at any one time, or in any single context, so listing an execution order isn't possible.

Hopefully the above distinctions will make it obvious which one to use in what circumstance.