Form validation handler for programmatic form submissions.
To test that the validation handler is correctly executed, the field value is explicitly required here.
function form_test_programmatic_form_validate($form, &$form_state) {
if (empty($form_state['values']['textfield'])) {
form_set_error('textfield', t('Textfield is required.'));
}
}