diff --git a/module/Application/src/Application/Validator/NumeroINSEEValidator.php b/module/Application/src/Application/Validator/NumeroINSEEValidator.php index 0d59fb61e16fadc6f0ceb8f67533d299026e4ed4..e4c823d604c32528fcddb2c8ee3e808edaba1006 100755 --- a/module/Application/src/Application/Validator/NumeroINSEEValidator.php +++ b/module/Application/src/Application/Validator/NumeroINSEEValidator.php @@ -202,7 +202,10 @@ class NumeroINSEEValidator extends NumeroINSEE private function isValidDepartementFrance() { /* Département du numéro INSEE */ - $iDepartement = strtoupper(str_pad((string)$this->getDepartement(), 3, '0', STR_PAD_LEFT)); + $iDepartement = (string)$this->getDepartement(); + if ($iDepartement != '97' && $iDepartement != '98') { + $iDepartement = strtoupper(str_pad($iDepartement, 3, '0', STR_PAD_LEFT)); + } /* Code du département issu du dossier */ $dDepartement = strtoupper(str_pad((string)$this->departement->getCode(), 3, '0', STR_PAD_LEFT)); @@ -220,6 +223,12 @@ class NumeroINSEEValidator extends NumeroINSEE return false; // département étranger } + //On traite les départements d'outre mer (peuvent etre sur deux ou trois chiffres, donc on teste que les deux premiers...) + if ($iDepartement == '97' || $iDepartement == '98') { + $dDepartement = substr($dDepartement, 0, 2); + if ($dDepartement == $iDepartement) return true; + } + if ($dDepartement == $iDepartement) return true; // Impec if ($iDepartement == '020') { @@ -310,11 +319,12 @@ class NumeroINSEEValidator extends NumeroINSEE if ($iDepartement == '99') { return 99; // étranger } - if ($iDepartement == '97' || $iDepartement == '98') { - $iDepartement = substr(strtoupper($this->value), 5, 3); - return (int)$iDepartement; - } + /* if ($iDepartement == '97' || $iDepartement == '98') { + $iDepartement = substr(strtoupper($this->value), 5, 3); + + return (int)$iDepartement; + }*/ return (int)$iDepartement; }