You are here

function iek_effect_natural_number_validate in Image effect kit 7

Validation function for color format.

6 string references to 'iek_effect_natural_number_validate'
iek_image_border_form in ./iek.module
Effect configuration form for iek_image_border.
iek_image_corner_form in ./iek.module
Effect configuration form for iek_image_corner.
iek_image_overlay_form in ./iek.module
Effect configuration form for iek_image_overlay.
iek_image_padding_form in ./iek.module
Effect configuration form for iek_image_padding.
iek_image_resize_form in ./iek.module
Effect configuration form for iek_image_resize.

... See full list

File

./iek.module, line 1170
Primarily Drupal hooks and global API functions to manipulate image styles.

Code

function iek_effect_natural_number_validate($element, &$form_state) {
  $allow_natural_number = isset($element['#allow_natural_number']) ? $element['#allow_natural_number'] : array(
    'negative',
    'zero',
    'positive',
  );
  $value = $element['#value'];
  if (!is_numeric($value)) {
    form_error($element, t('!name must be a number.', array(
      '!name' => $element['#title'],
    )));
  }
  elseif ($value > 0 && !in_array('positive', $allow_natural_number)) {
    form_error($element, t('!name must be not a positive number.', array(
      '!name' => $element['#title'],
    )));
  }
  elseif ($value == 0 && !in_array('zero', $allow_natural_number)) {
    form_error($element, t('!name must be not zero.', array(
      '!name' => $element['#title'],
    )));
  }
  elseif ($value < 0 && !in_array('negative', $allow_natural_number)) {
    form_error($element, t('!name must be not a negative number.', array(
      '!name' => $element['#title'],
    )));
  }
}