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:  * Validates a birth number.
16:  *
17:  * Taken from David Grudl's http://latrine.dgx.cz/jak-overit-platne-ic-a-rodne-cislo
18:  *
19:  * @category Jyxo
20:  * @package Jyxo_Input
21:  * @subpackage Validator
22:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23:  * @license https://github.com/jyxo/php/blob/master/license.txt
24:  * @author Jaroslav HanslĂ­k
25:  */
26: class Jyxo_Input_Validator_IsBirthNumber extends Jyxo_Input_Validator_AbstractValidator
27: {
28:     /**
29:      * Validates a value.
30:      *
31:      * @param mixed $value Input value
32:      * @return boolean
33:      */
34:     public function isValid($value)
35:     {
36:         $value = (string) $value;
37: 
38:         if (!preg_match('~^(\d{2})(\d{2})(\d{2})[ /]*(\d{3})(\d?)$~', trim($value), $matches)) {
39:             return false;
40:         }
41: 
42:         list(, $year, $month, $day, $ext, $control) = $matches;
43: 
44:         // Until 1954 9 numbers were used; can not check
45:         if ('' === $control) {
46:             if ($year >= 54) {
47:                 return false;
48:             } else {
49:                 return true;
50:             }
51:         }
52: 
53:         // Control number
54:         $mod = ($year . $month . $day . $ext) % 11;
55:         // Exception for ca 1000 numbers; no such numbers since 1985
56:         if (10 === $mod) {
57:             $mod = 0;
58:         }
59:         if ((int) $control !== $mod) {
60:             return false;
61:         }
62: 
63:         // Date check
64:         $year += $year < 54 ? 2000 : 1900;
65: 
66:         // 20, 50 or 70 can be added to month number
67:         if (($month > 70) && ($year > 2003)) {
68:             // Females since 2004 if all 4-digit extension combinations were used that day
69:             $month -= 70;
70:         } elseif ($month > 50) {
71:             // Females
72:             $month -= 50;
73:         } elseif (($month > 20) && ($year > 2003)) {
74:             // Males since 2004 if all 4-digit extension combinations were used that day
75:             $month -= 20;
76:         }
77: 
78:         // Date check
79:         if (!checkdate($month, $day, $year)) {
80:             return false;
81:         }
82: 
83:         // Ok
84:         return true;
85:     }
86: }
87: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0