CREATE FUNCTION `valid_regon`(`regon` varchar(255)) RETURNS int(1)
READS SQL DATA
BEGIN
DECLARE cs integer DEFAULT 0;
DECLARE m integer DEFAULT 0;
DECLARE i integer DEFAULT 0;
IF (char_length(regon) = 7) THEN
simple_loop: LOOP
SET i=i+1;
if i in (1) then
SET m = 2;
elseif i in (2) then
SET m = 3;
elseif i in (3) then
SET m = 4;
elseif i in (4) then
SET m = 5;
elseif i in (5) then
SET m = 6;
elseif i in (6) then
SET m = 7;
end if;
SET cs = cs + (m * substr(regon,i,1));
IF i=6 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
SET cs = cs % 11;
if ( cs = substr(regon,7,1) ) then
return 1;
else
return 0;
end if;
ELSEIF (char_length(regon) = 9) THEN
simple_loop: LOOP
SET i=i+1;
if i in (3) then
SET m = 2;
elseif i in (4) then
SET m = 3;
elseif i in (5) then
SET m = 4;
elseif i in (6) then
SET m = 5;
elseif i in (7) then
SET m = 6;
elseif i in (8) then
SET m = 7;
elseif i in (1) then
SET m = 8;
elseif i in (2) then
SET m = 9;
end if;
SET cs = cs + (m * substr(regon,i,1));
IF i=8 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
SET cs = cs % 11;
if ( cs = substr(regon,9,1) ) then
return 1;
else
return 0;
end if;
ELSEIF (char_length(regon) = 14) THEN
simple_loop: LOOP
SET i=i+1;
if i in (1,11) then
SET m = 2;
elseif i in (8) then
SET m = 3;
elseif i in (2,12) then
SET m = 4;
elseif i in (4) then
SET m = 5;
elseif i in (9) then
SET m = 6;
elseif i in (7) then
SET m = 7;
elseif i in (3,13) then
SET m = 8;
elseif i in (6) then
SET m = 9;
elseif i in (5) then
SET m = 0;
end if;
SET cs = cs + (m * substr(regon,i,1));
IF i=13 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
SET cs = cs % 11;
if ( cs = substr(regon,14,1) ) then
return 1;
else
return 0;
end if;
ELSE
return -1;
END IF;
END
Walidacja REGON dla MySQL
27 sierpnia 2010Walidacja PESEL dla MySQL
27 sierpnia 2010
CREATE FUNCTION `valid_pesel`(`pesel` varchar(255)) RETURNS int(1)
READS SQL DATA
BEGIN
DECLARE cs integer DEFAULT 0;
DECLARE m integer DEFAULT 0;
DECLARE i integer DEFAULT 0;
IF (char_length(pesel) = 11) THEN
simple_loop: LOOP
SET i=i+1;
if i in (1,5,9) then
SET m = 1;
elseif i in (2,6,10) then
SET m = 3;
elseif i in (3,7) then
SET m = 7;
elseif i in (4,8) then
SET m = 9;
end if;
SET cs = cs + (m * substr(pesel,i,1));
IF i=10 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
SET cs = cs % 10;
if (cs > 0) then
SET cs = 10 - cs;
end if;
if ( cs = substr(pesel,11,1) ) then
return 1;
else
return 0;
end if;
ELSE
return -1;
END IF;
END
Walidacja NIP dla MySQL
27 sierpnia 2010
CREATE FUNCTION `valid_nip`(`nip` varchar(255)) RETURNS int(1)
READS SQL DATA
BEGIN
DECLARE cs integer DEFAULT 0;
DECLARE m integer DEFAULT 0;
DECLARE i integer DEFAULT 0;
IF (char_length(nip) = 10) THEN
simple_loop: LOOP
SET i=i+1;
if i in (4) then
SET m = 2;
elseif i in (5) then
SET m = 3;
elseif i in (6) then
SET m = 4;
elseif i in (2,7) then
SET m = 5;
elseif i in (1,8) then
SET m = 6;
elseif i in (3,9) then
SET m = 7;
end if;
SET cs = cs + (m * substr(nip,i,1));
IF i=9 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
SET cs = cs % 11;
if ( cs = substr(nip,10,1) ) then
return 1;
else
return 0;
end if;
ELSE
return -1;
END IF;
END
Walidacja PESEL dla MSSQL
27 sierpnia 2010
CREATE FUNCTION valid_pesel( @pesel nvarchar(255) ) RETURNS INTEGER
AS
BEGIN
DECLARE @cs int
DECLARE @m int
DECLARE @i int
DECLARE @res int
SET @pesel = cast(@pesel as nvarchar)
SET @cs = 0
SET @m = 0
SET @i = 1
IF LEN(@pesel) = 11
begin
WHILE (@i <= 10)
BEGIN
if @i in (1,5,9) SET @m = 1
else if @i in (2,6,10) SET @m = 3
else if @i in (3,7) SET @m = 7
else if @i in (4,8) SET @m = 9
SET @cs = @cs + (@m * SUBSTRING(@pesel,@i,1))
SET @i = (@i + 1)
END
SET @cs = @cs % 10
if (@cs > 0) SET @cs = 10 - @cs
IF ( @cs = SUBSTRING(@pesel,11,1) )
SET @res = 1
ELSE
SET @res = 0
END
ELSE
BEGIN
SET @res = -1
END
RETURN @res
END
Walidacja REGON dla MSSQL
27 sierpnia 2010CREATE FUNCTION valid_regon( @regon nvarchar(255) ) RETURNS INTEGER
AS
BEGIN
DECLARE @cs int
DECLARE @m int
DECLARE @i int
DECLARE @res int
SET @regon = cast(@regon as nvarchar)
SET @cs = 0
SET @m = 0
SET @i = 1
IF LEN(@regon) = 7
BEGIN
WHILE (@i <= 6)
BEGIN
IF @i IN (1) SET @m = 2
ELSE IN @i in (2) SET @m = 3
ELSE IN @i in (3) SET @m = 4
ELSE IN @i in (4) SET @m = 5
ELSE IN @i in (5) SET @m = 6
ELSE IN @i in (6) SET @m = 7
SET @cs = @cs + (@m * SUBSTRING(@regon,@i,1))
SET @i = (@i + 1)
END
SET @cs = @cs % 11
IF ( @cs = SUBSTRING(@regon,7,1) )
SET @res = 1
ELSE
SET @res = 0
END
ELSE IF LEN(@regon) = 9
BEGIN
WHILE (@i <=
BEGIN
IF @i IN (3) SET @m = 2
ELSE IF @i IN (4) SET @m = 3
ELSE IF @i IN (5) SET @m = 4
ELSE IF @i IN (6) SET @m = 5
ELSE IF @i IN (7) SET @m = 6
ELSE IF @i IN (8) SET @m = 7
ELSE IF @i IN (1) SET @m = 8
ELSE IF @i IN (2) SET @m = 9
SET @cs = @cs + (@m * SUBSTRING(@regon,@i,1))
SET @i = (@i + 1)
END
SET @cs = @cs % 11
IF ( @cs = SUBSTRING(@regon,9,1) )
SET @res = 1
ELSE
SET @res = 0
END
ELSE IF LEN(@regon) = 14
BEGIN
WHILE (@i <= 13)
BEGIN
IF @i IN (1,11) SET @m = 2
ELSE IF @i IN (8) SET @m = 3
ELSE IF @i IN (2,12) SET @m = 4
ELSE IF @i IN (4) SET @m = 5
ELSE IF @i IN (9) SET @m = 6
ELSE IF @i IN (7) SET @m = 7
ELSE IF @i IN (3,13) SET @m = 8
ELSE IF @i IN (6) SET @m = 9
ELSE IF @i IN (5) SET @m = 0
SET @cs = @cs + (@m * SUBSTRING(@regon,@i,1))
SET @i = (@i + 1)
END
SET @cs = @cs % 11
IF ( @cs = SUBSTRING(@regon,14,1) )
SET @res = 1
ELSE
SET @res = 0
END
ELSE
BEGIN
SET @res = -1
END
RETURN @res
END
Walidacja NIP dla MSSQL
27 sierpnia 2010CREATE FUNCTION valid_nip( @nip nvarchar(255) ) RETURNS INTEGER AS BEGIN DECLARE @cs int DECLARE @m int DECLARE @i int DECLARE @res int SET @nip = cast(@nip as nvarchar) SET @cs = 0 SET @m = 0 SET @i = 1 IF LEN(@nip) = 10 begin WHILE (@i <= 9) BEGIN if @i in (4) SET @m = 2 else if @i in (5) SET @m = 3 else if @i in (6) SET @m = 4 else if @i in (2,7) SET @m = 5 else if @i in (1,8) SET @m = 6 else if @i in (3,9) SET @m = 7 SET @cs = @cs + (@m * SUBSTRING(@nip,@i,1)) SET @i = (@i + 1) END SET @cs = @cs % 11 IF ( @cs = SUBSTRING(@nip,10,1) ) SET @res = 1 ELSE SET @res = 0 END ELSE BEGIN SET @res = -1 END RETURN @res END
Walidacja NIP dla Zend Framework
21 kwietnia 2010Walidator nipu:
tutaj wgrywamy pliczek o nazwie Nip.php do katalogu /zend/Validate/
Kod validatora:
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Abstract
*/
require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Nip extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value is not of valid length
*/
const LENGTH = 'numLength';
/**
* Validation failure message key for when the value fails the mod checksum
*/
const CHECKSUM = 'numChecksum';
/**
* Digits filter for input
*
* @var Zend_Filter_Digits
*/
protected static $_filter = null;
/**
* @var array
*/
protected $_messageTemplates = array(
self::LENGTH => "'%value%' must contain 10 digits",
self::CHECKSUM => "Luhn algorithm (mod-11 checksum) failed on '%value%'"
);
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value contains a valid Eividencial namber message
*
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_setValue($value);
if (null === self::$_filter) {
/**
* @see Zend_Filter_Digits
*/
require_once 'Zend/Filter/Digits.php';
self::$_filter = new Zend_Filter_Digits();
}
$valueFiltered = self::$_filter->filter($value);
$length = strlen($valueFiltered);
if ($length != 10) {
$this->_error(self::LENGTH);
return false;
}
$mod = 11;
$sum = 0;
$weights = array (6, 5, 7, 2, 3, 4, 5, 6, 7);
preg_match_all("/\d/", $valueFiltered, $digits) ;
$valueFilteredArray = $digits[0];
foreach ( $valueFilteredArray as $digit )
{
$weight = current($weights);
$sum += $digit * $weight;
next($weights);
}
if ( ( ($sum % $mod == 10) ? 0 : $sum % $mod) != $valueFilteredArray[$length - 1] )
{
$this->_error(self::CHECKSUM, $valueFiltered);
return false;
}
return true;
}
}
Wywołanie:
$validator = new Zend_Validate_Nip();
if (!$validator->isValid('000-00-00-00')) {
$messages = $validator->getMessages();
echo current($messages);
}
oczywiscie wlasne komunikaty : stale: numLength, numChecksum przy budowaniu formularzy np. :
$element->setValidators(
array(
array('Nip', true, array(
'messages' => array(
'numLength' => "'%value%' must contain 10 digits",
'numChecksum' => "Luhn algorithm (mod-11 checksum) failed on %value%'"
)))
));
Walidacja ISBN dla Zend Framework
23 listopada 2009
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Abstract
*/
require_once 'Zend/Validate/Abstract.php';
/**
* Zend_Validate_StringLength
*/
require_once 'Zend/Validate/StringLength.php';
/**
* Zend_Validate_Digits
*/
require_once 'Zend/Validate/Digits.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Isbn extends Zend_Validate_Abstract
{
/**
* Sets ISBN-10 format
*/
const ISBN10 = 10;
const LENGTH10 = 'numLength10';
const CHECKSUM10 = 'numChecksum10';
/**
* Sets ISBN-13 format
*/
const ISBN13 = 13;
const LENGTH13 = 'numLength13';
const CHECKSUM13 = 'numChecksum13';
/**
* Sets Other Const
*/
const INVALID_SET = 'invSet';
const INVALID_CHARACTERS = 'invCharacters';
const UNKNOWN_VERSION = 'unknownVersion';
const ISEMPTY = 'isEmpty';
/**
* @var array
*/
protected $_messageTemplates = array(
self::INVALID_SET => "'%value%' - invalid isbn version set",
self::ISEMPTY => "no isbn versions allowed",
self::UNKNOWN_VERSION => "unknown ISBN version given",
self::INVALID_CHARACTERS => "'%value%' contains invalid characters",
self::LENGTH10 => "'%value%' must contain 10 digits",
self::LENGTH13 => "'%value%' must contain 13 digits",
self::CHECKSUM10 => "Luhn algorithm (mod-11 checksum) failed on '%value%'",
self::CHECKSUM13 => "Luhn algorithm (mod-11 checksum) failed on '%value%'",
);
/**
* @acces protected
* @var integer
*/
protected $_allowVersionArr = array(
self::ISBN13=>1,
self::ISBN10=>1
);
/**
* Sets the allow version.
*
* @access public
* @param integer $version
* @return bool
*/
public function allowVersion($version)
{
if (($version != self::ISBN10) && ($version != self::ISBN13)) {
$this->_error(self::UNKNOWN_VERSION);
return false;
}
$this->_allowVersionArr[$version] = 1;
return true;
}
/**
* Sets the allow version.
*
* @access public
* @param integer $version
* @return bool
*/
public function disallowVersion($version)
{
if (($version != self::ISBN10) && ($version != self::ISBN13)) {
$this->_error(self::UNKNOWN_VERSION);
return false;
}
$this->_allowVersionArr[$version] = 0;
return true;
}
/**
* Returns true if the given value is a valid ISBN-10 or ISBN-13.
*
* @access public
* @param string $value
* @return bool
*/
public function isValid($value)
{
if (array_sum($this->_allowVersionArr) == 0) {
$this->_error(self::ISEMPTY);
return false;
}
$valueString = (string) $value;
$return = true;
// all isbn numbers can start with "ISBN"
if (substr($valueString,0,4) == 'ISBN') {
$valueString = substr($valueString, 4);
}
// " " and "-" are allowed separators in all isbn numbers
$valueString = str_replace(array(' ', '-'), '', $valueString);
// all other chars must be digits
$digits = new Zend_Validate_Digits();
if (!$digits->isValid($valueString)) {
$this->_error(self::INVALID_CHARACTERS, $value);
$return = false;
}
$length = strlen($valueString);
if ($return === true && $this->_allowVersionArr[self::ISBN10] && $length == 10) {
$return = $this->_validateIsbn10($valueString);
} elseif ($return === true && $this->_allowVersionArr[self::ISBN13] && $length == 13) {
$return = $this->_validateIsbn13($valueString);
} else {
$this->_error(self::INVALID_SET, $value);
return false;
}
}
/**
* Validates ISBN-10
*
* @access protected
* @param string $value
* @return bool
*/
protected function _validateIsbn10($value)
{
$stringLength = new Zend_Validate_StringLength(10, 10);
if (!$stringLength->isValid($value)) {
$this->_error(self::LENGTH10, $value);
return false;
}
$remainder = $value[9];
$checksum = 0;
for ($i=10, $a=0; $i>1; $i--, $a++)
{
$digit = (int) $value[$a];
$checksum += $digit * $i;
}
$valide = ((11 - ($checksum % 11)) == $remainder);
if (!$valide) {
$this->_error(self::CHECKSUM10, $value);
}
return $valide;
}
/**
* Validates ISBN-13
*
* @access protected
* @param string $value
* @return bool
*/
protected function _validateIsbn13($value)
{
$stringLength = new Zend_Validate_StringLength(13, 13);
if (!$stringLength->isValid($value)) {
$this->_error(self::LENGTH13, $value);
return false;
}
$remainder = $value[12];
$checksum = 0;
for ($i=0; $i<12; $i++)
{
$multi = (($i % 2) == 1) ? 1 : 3;
$digit = (int) $value[$i];
$checksum += $digit * $multi;
}
$valide = ((10 - ($checksum % 10)) == $remainder);
if (!$valide) {
$this->_error(self::CHECKSUM13, $value);
}
return $valide;
}
}
$validator4 = new Zend_Validate_Isbn();
if (!$validator4->isValid('0000000000')) {
$messages4 = $validator4->getMessages();
echo current($messages4);
}
$element->setValidators(
array(
array('Isbn', true, array(
'messages' => array(
'numLength' => "'%value%' must contain either 10 or 13 digits",
'numChecksum' => "Luhn algorithm (mod-10 checksum) failed on '%value%'"
)))
));
Walidacja REGON dla Zend Framework
23 listopada 2009
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Abstract
*/
require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Regon extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value is not of valid length
*/
const LENGTH = 'numLength';
/**
* Validation failure message key for when the value fails the mod checksum
*/
const CHECKSUM = 'numChecksum';
/**
* Digits filter for input
*
* @var Zend_Filter_Digits
*/
protected static $_filter = null;
/**
* @var array
*/
protected $_messageTemplates = array(
self::LENGTH => "'%value%' must contain either 7, 9 or 14 digits",
self::CHECKSUM => "Luhn algorithm (mod-11 checksum) failed on '%value%'"
);
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value contains a valid Eividencial namber message
*
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_setValue($value);
if (null === self::$_filter) {
/**
* @see Zend_Filter_Digits
*/
require_once 'Zend/Filter/Digits.php';
self::$_filter = new Zend_Filter_Digits();
}
$valueFiltered = self::$_filter->filter($value);
$length = strlen($valueFiltered);
if ($length != 7 && $length != 9 && $length != 14) {
$this->_error(self::LENGTH);
return false;
}
$mod = 11;
$sum = 0;
$weights[7] = array (2, 3, 4, 5, 6, 7);
$weights[9] = array (8, 9, 2, 3, 4, 5, 6, 7);
$weights[14] = array (2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8);
preg_match_all("/\d/", $valueFiltered, $digits) ;
$valueFilteredArray = $digits[0];
$weights = $weights[$length];
foreach ( $valueFilteredArray as $digit )
{
$weight = current($weights);
$sum += $digit * $weight;
next($weights);
}
if ( ( ($sum % $mod == 10) ? 0 : $sum % $mod) != $valueFilteredArray[$length - 1] )
{
$this->_error(self::CHECKSUM, $valueFiltered);
return false;
}
return true;
}
}
$validator3 = new Zend_Validate_Regon();
if (!$validator3->isValid('0000000')) {
$messages3 = $validator3->getMessages();
echo current($messages3);
}
$element->setValidators(
array(
array('Regon', true, array(
'messages' => array(
'numLength' => "'%value%' must contain either 7, 9 or 14 digits",
'numChecksum' => "Luhn algorithm (mod-11 checksum) failed on '%value%'"
)))
));
Walidacja PESEL dla Zend Framework
23 listopada 2009
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Abstract
*/
require_once 'Zend/Validate/Abstract.php';
/**
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Pesel extends Zend_Validate_Abstract
{
/**
* Validation failure message key for when the value is not of valid length
*/
const LENGTH = 'numLength';
/**
* Validation failure message key for when the value fails the mod checksum
*/
const CHECKSUM = 'numChecksum';
/**
* Digits filter for input
*
* @var Zend_Filter_Digits
*/
protected static $_filter = null;
/**
* @var array
*/
protected $_messageTemplates = array(
self::LENGTH => "'%value%' must contain 11 digits",
self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'"
);
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value contains a valid Eividencial namber message
*
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_setValue($value);
if (null === self::$_filter) {
/**
* @see Zend_Filter_Digits
*/
require_once 'Zend/Filter/Digits.php';
self::$_filter = new Zend_Filter_Digits();
}
$valueFiltered = self::$_filter->filter($value);
$length = strlen($valueFiltered);
if ($length != 11) {
$this->_error(self::LENGTH);
return false;
}
$mod = 10;
$sum = 0;
$weights = array (1, 3, 7, 9, 1, 3, 7, 9, 1, 3);
preg_match_all("/\d/", $valueFiltered, $digits) ;
$valueFilteredArray = $digits[0];
foreach ( $valueFilteredArray as $digit )
{
$weight = current($weights);
$sum += $digit * $weight;
next($weights);
}
if ( (((10 - ($sum % $mod) == 10) ? 0 : 10) - ($sum % $mod)) != $valueFilteredArray[$length - 1] )
{
$this->_error(self::CHECKSUM, $valueFiltered);
return false;
}
return true;
}
}
$validator2 = new Zend_Validate_Pesel();
if (!$validator2->isValid('00000000000')) {
$messages2 = $validator2->getMessages();
echo current($messages2);
}
$element->setValidators(
array(
array('Pesel', true, array(
'messages' => array(
'numLength' => "'%value%' must contain 10 digits",
'numChecksum' => "Luhn algorithm (mod-11 checksum) failed on '%value%'"
)))
));