function regcode_admin_create_validate in Registration codes 6
Same name and namespace in other branches
- 6.2 regcode.admin.php \regcode_admin_create_validate()
- 7.2 regcode.admin.inc \regcode_admin_create_validate()
- 7 regcode.admin.php \regcode_admin_create_validate()
Validator for create form
File
- ./
regcode.admin.php, line 167 - Functions and pages needed for the administration interface for the regcode module.
Code
function regcode_admin_create_validate($form, &$form_state) {
foreach (array(
'regcode_create_begins',
'regcode_create_expires',
) as $field) {
if (empty($form_state['values'][$field])) {
continue;
}
$time = strtotime($form_state['values'][$field]);
if (!$time) {
form_set_error($field, t('Invalid date'));
}
$time = date("Y", $time);
if ($time > 2030 || $time < 1980) {
form_set_error($time, t('Date should be between years @start and @end.', array(
'@start' => 1980,
'@end' => 2030,
)));
}
}
if (!is_numeric($form_state['values']['regcode_create_maxuses']) || $form_state['values']['regcode_create_maxuses'] < 0) {
form_set_error('regcode_create_maxuses', t('Invalid maxuses, specify a positive integer or enter "0" for unlimited'));
}
}