diff --git a/src/lib/auditors/dossiers_legislatifs.ts b/src/lib/auditors/dossiers_legislatifs.ts index 04bf87a..2587098 100644 --- a/src/lib/auditors/dossiers_legislatifs.ts +++ b/src/lib/auditors/dossiers_legislatifs.ts @@ -12,6 +12,7 @@ import { auditSwitch, auditString, auditTest, + auditNumber, } from "@auditors/core" function auditContenu(audit: Audit, dataUnknown: unknown): [unknown, unknown] { @@ -177,7 +178,23 @@ function auditLigne(audit: Audit, dataUnknown: unknown): [unknown, unknown] { const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - for (const key of ["ARTICLE", "BASE_LEGALE", "DECRET", "OBJET"]) { + audit.attribute( + data, + "ARTICLE", + true, + errors, + remainingKeys, + auditSwitch( + [ + auditNumber, + auditInteger, + auditFunction((article) => article.toString()), + ], + auditTrimString, + ), + auditEmptyToNull, + ) + for (const key of ["BASE_LEGALE", "DECRET", "OBJET"]) { audit.attribute( data, key, @@ -224,15 +241,10 @@ function auditLigne(audit: Audit, dataUnknown: unknown): [unknown, unknown] { errors, remainingKeys, auditSwitch( - [auditInteger, auditFunction((numero) => [numero])], - [ - auditString, - auditFunction((numeros) => numeros.split(",")), - auditArray(auditStringToNumber, auditInteger), - ], + [auditNumber, auditInteger, auditFunction((numero) => numero.toString())], + auditTrimString, ), - auditArray(auditRequire), - auditRequire, + auditEmptyToNull, ) return audit.reduceRemaining(data, errors, remainingKeys) diff --git a/src/lib/legal.ts b/src/lib/legal.ts index 9ea4906..b2fa11f 100644 --- a/src/lib/legal.ts +++ b/src/lib/legal.ts @@ -216,7 +216,7 @@ export interface Ligne { "@id": string // Always a JORFARTI ID "#text": string }> - NUMERO_ORDRE: number[] + NUMERO_ORDRE?: string OBJET?: string } diff --git a/src/scripts/export_dole_echeancier_to_csv.ts b/src/scripts/export_dole_echeancier_to_csv.ts index 90c90a4..5ab5514 100644 --- a/src/scripts/export_dole_echeancier_to_csv.ts +++ b/src/scripts/export_dole_echeancier_to_csv.ts @@ -47,9 +47,7 @@ async function exportEcheanciers(csvFilePath: string): Promise { lien_article_texte: lienArticle["#text"], derniere_maj: echeancier["@derniere_maj"], id: dossierLegislatif.META.META_COMMUN.ID, - numero_ordre: ligne.NUMERO_ORDRE.map((numero) => - numero.toString(), - ).join(", "), + numero_ordre: ligne.NUMERO_ORDRE, objet: ligne.OBJET, titre: dossierLegislatif.META.META_DOSSIER_LEGISLATIF.TITRE, })