Example #1
0
 function validateIbanHTTPInput($iban, $contentObjectAttribute)
 {
     if (!Iban::validate($iban)) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The IBAN code is not valid.'));
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
Example #2
0
 /**
  * Calculate IBAN code.
  *
  * Calculate IBAN code from BBAN code and country to which it belongs.
  *
  * @param  string $country Country of BBAN code.
  * @param  string $bban    BBAN code.
  * @return array
  * array[0]:null|string = error,<br />
  * array[1]:null|string = IBAN code if array[0] is null.
  */
 static function calculate($country, $bban)
 {
     // Checks if the function reveives a country string.
     if (!is_string($country)) {
         return array(Iban::$error[6], null);
     }
     // Checks if the country exists in the database.
     if (is_null($countryData = getCountry($country))) {
         return array(Iban::$error[0], null);
     }
     // Checks if the function receives a bban string.
     if (!is_string($bban)) {
         return array(Iban::$error[7], null);
     }
     // Converts uppercase.
     $bban = strtoupper($bban);
     // Checks if the length of the code provided corresponds to the country indicated.
     if (strlen($bban) != $countryData['bbanLength']) {
         return array(Iban::$error[8], null);
     }
     // Checks BBAN structure.
     if (!Iban::validateStructure($countryData['bbanStructure'], $bban, 0)) {
         return array(Iban::$error[9], null);
     }
     // BBAN check digits test.
     $bbanCDTResult = bbanCheckDigitTest($country, $bban);
     if ($bbanCDTResult[0]) {
         if (!$bbanCDTResult[1]) {
             return array(Iban::$error[10], null);
         }
     }
     // Calculate IBAN code.
     $checkDigits = Iban::checkDigits($country . '00' . $bban);
     if ($checkDigits < 10) {
         return array(null, $country . '0' . $checkDigits . $bban);
     } else {
         return array(null, $country . $checkDigits . $bban);
     }
 }
Example #3
0
 public function testEmptyIbanAsInvalid()
 {
     //self::markTestIncomplete( "Not implemented" );
     $this->assertEquals(Iban::validate(''), false);
     $this->assertEquals(Iban::validate(' '), false);
 }