You are here

function isbn_validate_number in ISBN Field 6

2 calls to isbn_validate_number()
isbn_field in ./isbn.module
Implementation of hook_field(). http://drupal.org/node/342996
isbn_validate_ajax in ./isbn.module
Ajax callback function for validating an ISBN

File

./isbn.module, line 39
Defines ISBN field types.

Code

function isbn_validate_number($number, $format) {
  module_load_include('inc', 'isbn');
  $number = isbn_clean($number);
  $validate_function = "isbn_validate_{$format}";
  $return = $validate_function($number);

  //Set invalid message.
  if ($return['valid'] == false && !isset($return['message'])) {
    $return['message'] = 'confirmFailure';
    $length = strlen($number);
    if ($length < $format) {
      $return['message'] = 'notEnoughDigits';
    }
    elseif ($length > $format) {
      $return['message'] = 'tooManyDigits';
    }
  }
  return $return;
}