You can use form_set_value() in your validation handler. Let's say you are retrieving a user ID from a remote API, by sending the user's name. In your form definition, you can have:
$form['user'] = array (
'#type' => 'textfield',
'#title' => t('User to fetch'),
);
In your validation handler, you can retrieve the value. If a value exists you save it using form_set_value, and if it doesn't, you set an error:
$remote_user_id = retrieve_uid_from_api($form_state['values']['user']);
if($remote_user_id) {
form_set_value($form['user'], $remote_user_id);
}
else {
form_set_error('user', t('%user does not exist in the remote API', array('%user' => $form_state['values']['user']));
}
So in your submit function, `$form_state['values']['user'] will now contain the User ID from the remote API:
$remote_user_id = $form_state['values']['user'];