How to validate a form against a custom user profile field? I unsuccessfully tried https://www.drupal.org/project/rules_forms for forms validation so I am writing my own little validation module.
Basically, on node creation I want a validation against a custom user profile field (machine name: field_points). When the user enters on node creation more points then he has on his profile, an error message should appear.
Static validation against a number works just fine, but how can I access custom fields of the user object? Using devel, for some reason they don't show up in dpm($user).


function custom2_form_contenttype_node_form_alter(&amp;$form, &amp;$form_state, &amp;$form_id) {
drupal_set_message(&quot;Form ID is : &quot; . $form_id);
dpm($form);
//$form['field_points']['und']['0']['value']['#default_value'] = 164;
$form['#validate'][] = 'custom2_form_contenttype_node_form_validate';
}

function custom2_form_contenttype_node_form_validate($form, $form_state) {
global $user;
dpm($user);
$profilePoints = $user-&gt;field_points;
$enteredPoints = $form_state['values']['field_points']['und']['0']['value'];
dpm($form['#validate']);
dpm($form_state);
if ($enteredPoints &gt; $profilePoints) {
   form_set_error('field_points', '&quot;You can only spend&quot; .     $profilePoints . &quot; //points.&quot;');
   }

}
EDIT: uploaded devel user screenshot
Try with this code it is helpful for you 

&lt;?php

function mymodule_form_alter(&amp;$form, &amp;$form_state, &amp;$form_id) {
      if ($form_id == 'form_id') {
    $form['#validate'][] = 'my_validation';
                                      }
                                                                }


function my_validation($node, $form, $form_state){

    if (!isset($form_state['values']['field_text']['und'][0]['field_text']['und'][0]['value']))
    {
        form_set_error('Text', 'Select text'); 
        }

}