Validate all instances of a field programmatically What is the best way(hook) to validate all instances of a field programmatically? I have a lot of content types having the same fields like field_phone. I want to programmatically validate field_phone everywhere it is used.
You could implement hook_field_validate and check if its the correct instance. Doesnt work if the field is not defined by the module.

One way to build that would use hook_form_alter and add element_validator if the field exists on the form.

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
   if (isset($form['field_phone'])) {
      $form['field_phone']['#element_validate'][] = 'mymodule_somevalidator';
    }
 }

function mymodule_somevalidator($element, &amp;$form_state) {
  if (!empty($element['#value']) &amp;&amp; !is_numeric(parse_size($element['#value'])) {
    form_error($element, t('The "!name" must be x', array('!name' =&gt; t($element['title']))));
  }
}