API page: http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...
I find the documentation for hook_field_validate to be infuriating. The first time I tried implementing this hook, I didn't know how much validation I needed to do – do I need to validate form input lengths to be no greater than the varchar lengths in my hook_field_schema definition (I don't believe I do, since I can just set a value for the #maxlength key in hook_field_widget_form).
The above issue might simply be a result of my inexperience, but the other issue I ran into appears to be more clear-cut. Nowhere in the hook_field_validate documentation does it mention hook_field_widget_error, which is necessary to implement for the message key values to be printed via form_error in place of the error key values found in the $errors[$field['field_name']][$langcode][$delta][] array definition in hook_field_validate. I wasted probably two hours on this (it doesn't help that neither the Drupal 7 Module Development book nor various online documentation I found mention hook_field_widget_error); am I missing something or is this an obvious omission?
Comments
Comment #1
jhodgdonThanks, good ideas on what to document...
Comment #2
chx commentedFrom #369964: Refactor field validation and error reporting your only problem can be if your error is keyed wrong and you have FIELD_BEHAVIOR_CUSTOM defined.
Comment #3
jhodgdonWe probably still need the documentation update for Drupal 7 though.
Comment #4
phryk commentedYes please, this just cost me about an hour for D7 until I saw the comment. :<