Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

  • Jyxo_Input_Validator
  • Jyxo_Input_Validator_AbstractValidator
  • Jyxo_Input_Validator_Callback
  • Jyxo_Input_Validator_Equals
  • Jyxo_Input_Validator_InArray
  • Jyxo_Input_Validator_IsArray
  • Jyxo_Input_Validator_IsBankAccountNumber
  • Jyxo_Input_Validator_IsBirthNumber
  • Jyxo_Input_Validator_IsCompanyId
  • Jyxo_Input_Validator_IsCountryCode
  • Jyxo_Input_Validator_IsDate
  • Jyxo_Input_Validator_IsDateTime
  • Jyxo_Input_Validator_IsEmail
  • Jyxo_Input_Validator_IsIban
  • Jyxo_Input_Validator_IsInt
  • Jyxo_Input_Validator_IsIpV4
  • Jyxo_Input_Validator_IsIpV6
  • Jyxo_Input_Validator_IsNumeric
  • Jyxo_Input_Validator_IsPhone
  • Jyxo_Input_Validator_IsTaxId
  • Jyxo_Input_Validator_IsUrl
  • Jyxo_Input_Validator_IsZipCode
  • Jyxo_Input_Validator_LessThan
  • Jyxo_Input_Validator_NotEmpty
  • Jyxo_Input_Validator_Regex
  • Jyxo_Input_Validator_StringLengthBetween
  • Jyxo_Input_Validator_StringLengthGreaterThan
  • Jyxo_Input_Validator_StringLengthLessThan
  • Jyxo_Input_Validator_Upload

Interfaces

  • Jyxo_Input_Validator_ErrorMessage
  • Jyxo_Input_ValidatorInterface

Exceptions

  • Jyxo_Input_Validator_Exception
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: /**
15:  * (Czech) bank number validator.
16:  *
17:  * @category Jyxo
18:  * @package Jyxo_Input
19:  * @subpackage Validator
20:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
21:  * @license https://github.com/jyxo/php/blob/master/license.txt
22:  * @author Jaroslav HanslĂ­k
23:  */
24: class Jyxo_Input_Validator_IsBankAccountNumber extends Jyxo_Input_Validator_AbstractValidator
25: {
26:     /**
27:      * Validates a value.
28:      *
29:      * @param mixed $value Input value
30:      * @return boolean
31:      */
32:     public function isValid($value)
33:     {
34:         if (!preg_match('~^(?:(\d{1,6})-)?(\d{2,10})/(\d{4})$~i', (string) $value, $matches)) {
35:             return false;
36:         }
37: 
38:         list(, $prefix, $base, $bankCode) = $matches;
39: 
40:         // Bank codes valid in the Czech Republic on 2008-09-01
41:         static $bankCodes = array(
42:             '0100', '0300', '0400', '0600', '0700', '0800', '2010', '2020', '2030', '2040',
43:             '2050', '2070', '2100', '2200', '2400', '2600', '2700', '3500', '4000', '4300',
44:             '5000', '5400', '5500', '5800', '6000', '6100', '6200', '6210', '6300', '6700',
45:             '6800', '7910', '7940', '7950', '7960', '7970', '7980', '7990', '8030', '8040',
46:             '8060', '8090', '8150', '8200'
47:         );
48: 
49:         // Valid bank code
50:         if (!in_array($bankCode, $bankCodes)) {
51:             return false;
52:         }
53: 
54:         // Prefix check
55:         $prefix = str_pad($prefix, 6, '0', STR_PAD_LEFT);
56:         $mod = ($prefix[0] * 10 + $prefix[1] * 5 + $prefix[2] * 8 + $prefix[3] * 4 + $prefix[4] * 2 + $prefix[5] * 1) % 11;
57:         if (0 !== $mod) {
58:             return false;
59:         }
60: 
61:         // Base number part check
62:         $base = str_pad($base, 10, '0', STR_PAD_LEFT);
63:         $mod = ($base[0] * 6 + $base[1] * 3 + $base[2] * 7 + $base[3] * 9 + $base[4] * 10 + $base[5] * 5 + $base[6] * 8 + $base[7] * 4 + $base[8] * 2 + $base[9] * 1) % 11;
64:         if (0 !== $mod) {
65:             return false;
66:         }
67: 
68:         return true;
69:     }
70: }
71: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0