You are here

function uc_discounts_admin_generate_codes_form_validate in Ubercart Discounts (Alternative) 7.2

Form validation handler for uc_discounts_admin_generate_codes_form().

See also

uc_discounts_admin_generate_codes()

uc_discounts_admin_generate_codes_form()

uc_discounts_admin_generate_codes_form_submit()

File

uc_discounts/uc_discounts.admin.inc, line 1488
Admin forms and functions for uc_discounts module.

Code

function uc_discounts_admin_generate_codes_form_validate($form, &$form_state) {
  if (!is_numeric($form_state['values']['num']) || $form_state['values']['num'] <= 0) {
    form_set_error('num', t('Number of discounts must be a number greater than 0.'));
  }
  if (substr_count($form_state['values']['pattern'], '%') < 2) {
    form_set_error('pattern', t('Code pattern must have at least two random digits or letters to ensure uniqueness.'));
  }
}