Skip to content

Commit

Permalink
fix: bug uid_adresses not interpreted
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Jun 5, 2024
1 parent e73c7d2 commit 49ba182
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ exports.fields = {
aliases: ["uid_adress"],
parse(v, { addError, setAdditionnalValues }) {
const regUuidCommune =
/@c([A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12})/gi;
/@c:([A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12})/gi;
const regUuidToponyme =
/@v[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}/gi;
/@v:[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}/gi;
const regUuidAdresse =
/@a[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}/gi;
/@a:[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}/gi;

const [uuidCommune] = v.match(regUuidCommune) || [];
const [uuidToponyme] = v.match(regUuidToponyme) || [];
const [uuidAdresse] = v.match(regUuidAdresse) || [];

const idBanCommune = uuidCommune?.substr(2) || null;
const idBanToponyme = uuidToponyme?.substr(2) || null;
const idBanAdresse = uuidAdresse?.substr(2) || null;
const idBanCommune = uuidCommune?.substr(3) || null;
const idBanToponyme = uuidToponyme?.substr(3) || null;
const idBanAdresse = uuidAdresse?.substr(3) || null;

if (
!isUuid(idBanCommune) ||
Expand Down
2 changes: 1 addition & 1 deletion lib/validate/__tests__/1.4/data/1.3-valid-uid_adresse.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cle_interop;uid_adresse;commune_insee;voie_nom;numero;suffixe;commune_nom;position;long;lat;x;y;source;date_der_maj
31591_xxxx_00009;@c0246e48c-f33d-433a-8984-034219be842e @v8a3bab10-f329-4ce3-9c7d-280d91a8053a @a3c87abe4-887b-46ee-9192-5c1b35a06625;31591;Rue des 3 Places;9;;Escoulis;entrée;1.028392;43.111637;539416.13;6225601.11;;2020-11-09
31591_xxxx_00009;@c:0246e48c-f33d-433a-8984-034219be842e @v:8a3bab10-f329-4ce3-9c7d-280d91a8053a @a:3c87abe4-887b-46ee-9192-5c1b35a06625;31591;Rue des 3 Places;9;;Escoulis;entrée;1.028392;43.111637;539416.13;6225601.11;;2020-11-09
1 change: 0 additions & 1 deletion lib/validate/__tests__/1.4/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ test("Warning rows.ids_required_every (file 1.4)", async (t) => {
test("Read uid_adresse", async (t) => {
const buffer = await readAsBuffer("1.3-valid-uid_adresse.csv");
const report = await validate(buffer, { profile: "1.4" });
console.log();
t.is(report.encoding, "utf-8");
t.is(report.parseOk, true);
t.is(report.profilesValidation["1.4"].isValid, true);
Expand Down

0 comments on commit 49ba182

Please sign in to comment.