socrates
socrates copied to clipboard
France Metropolitan Lyon Region Validation
On the region digits, there is at least one case Metropolitan Lyon which has a letter in the COG.
'69M' => 'Metropolitan Lyon',
But the validation algorithm for France will throw a cast error when trying to parse an id that includes that COG.
public function validate(string $id): bool
{
$id = $this->sanitize($id);
$checksum = (int) substr($id, -2);
$id = substr($id, 0, -2);
$result = 97 - ((int) $id % 97); // cast error for an id like 1510269M02043
return $checksum === $result;
}
I can't find any documentation on how to perform the control digit calculation for a scenario like that though.
We should look around for some implementations of the French validator
@all-contributors please add @SLourenco for bug, doc and code
I've been looking into it and found that Corsica has the same problem. It is referenced as 2A and 2B.
For Corsica, the wiki page provides a way to validate the INSEE. (https://fr.wikipedia.org/wiki/Num%C3%A9ro_de_s%C3%A9curit%C3%A9_sociale_en_France). But not for Lyon...
So are there different ways of validating the INSEE depending on the region? Yikes...
I've just updated the ID validation for Corsica citizens, so it is now possible to validate and extract information from them.
You can check it at french-id-fixes branch.
Regarding Lyon... Still no clue how to work that around... 🤔
De-scoping this from the v1.1.1 for now, because we're blocked