Unique field value for all nodes and content types
Check out this example 

function custom_node_validate($node, $form) {
  if ($node-&gt;type == 'page') {
    //retrieve the value for your field using Entity API
    $wrapper = entity_metadata_wrapper('node', $node);
    $value = $wrapper-&gt;field_collection-&gt;field_unique-&gt;value();

    //Execute a count query to see if there's other similar values.
    $query = new EntityFieldQuery;
    $query-&gt;entityCondition('entity_type', 'field_collection_item')
      -&gt;fieldCondition('field_unique', 'value', $value)
      -&gt;count();
    $count = $query-&gt;execute();
    if ($count &gt; 1) {
      form_set_error('field_unique', 'Unique field value is already used.');
    }
  }
}