Automatic Validation Using drupal_form_submit
Field validation is made only against node form submission, so you need to imitate this in your code.

If you are using Drupal 6, try this solution:https://stackoverflow.com/a/6471821/1387163

For Drupal 7 solution can as following:

$node = new StdClass();

$node-&gt;type = 'my_type';
node_object_prepare($node);

// assign node field values here ...

$form_state = array (
  'node' =&gt; $node,
  'values' =&gt; (array)$node,
);
$form = drupal_get_form($node-&gt;type. '_node_form', $node);

node_form_validate($form, $form_state);

$errors = form_get_errors();

if ($errors) {
   // ...
} else {
   // ...
}