socrates icon indicating copy to clipboard operation
socrates copied to clipboard

France Metropolitan Lyon Region Validation

Open SLourenco opened this issue 4 years ago • 7 comments

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.

SLourenco avatar Jun 13 '20 11:06 SLourenco

We should look around for some implementations of the French validator

AlexOlival avatar Jun 14 '20 14:06 AlexOlival

@all-contributors please add @SLourenco for bug, doc and code

AlexOlival avatar Jun 14 '20 14:06 AlexOlival

@AlexOlival

I've put up a pull request to add @SLourenco! :tada:

allcontributors[bot] avatar Jun 14 '20 14:06 allcontributors[bot]

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...

JoaoFSCruz avatar Jun 14 '20 15:06 JoaoFSCruz

So are there different ways of validating the INSEE depending on the region? Yikes...

AlexOlival avatar Jun 14 '20 15:06 AlexOlival

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... 🤔

JoaoFSCruz avatar Jun 16 '20 17:06 JoaoFSCruz

De-scoping this from the v1.1.1 for now, because we're blocked

AlexOlival avatar Jun 30 '20 15:06 AlexOlival