[+] Project : B2B Features
This commit is contained in:
@@ -934,5 +934,36 @@ class ValidateCore
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate SIRET Code
|
||||
* @static
|
||||
* @param $siret SIRET Code
|
||||
* @return boolean Return true if is valid
|
||||
*/
|
||||
public static function isSiret($siret)
|
||||
{
|
||||
if (Tools::strlen($siret) != 14)
|
||||
return false;
|
||||
$sum = 0;
|
||||
for($i=0; $i != 14; $i++) {
|
||||
$tmp = ((($i + 1) % 2) + 1) * intval($siret[$i]);
|
||||
if ($tmp >= 10)
|
||||
$tmp -= 9;
|
||||
$sum += $tmp;
|
||||
}
|
||||
return ($sum % 10 === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate APE Code
|
||||
* @static
|
||||
* @param $ape APE Code
|
||||
* @return boolean Return true if is valid
|
||||
*/
|
||||
public static function isApe($ape)
|
||||
{
|
||||
return (bool)preg_match('/^[0-9]{3,4}[a-zA-Z]{1}$/s', $ape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user