Skip to content

Commit

Permalink
fix: bug validateur profile
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Jun 10, 2024
1 parent 0780768 commit c1d207d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions lib/compose/import-from-api-depot.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const {validate} = require('@ban-team/validateur-bal')
const {validate, profiles} = require('@ban-team/validateur-bal')
const {getRevisionFile} = require('../util/api-depot.cjs')

function isErroredRow(row) {
return row.errors.some(({level}) => level === 'E')
}

const relaxProfile = 'relax'
const defaultProfile = '1.3-relax'

async function importFromApiDepot(revision) {
const revisionFile = await getRevisionFile(revision._id)
const validationResult = await validate(revisionFile, {profile: relaxProfile})

if (profiles[defaultProfile]) {
throw new Error('Le profile du validateur n’existe pas')
}

const validationResult = await validate(revisionFile, {profile: defaultProfile})

if (!validationResult.parseOk) {
throw new Error(`Le fichier BAL récupéré n’est pas valide : ${revision._id}`)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@ban-team/fantoir": "^0.15.0",
"@ban-team/gazetteer": "^3.2.0",
"@ban-team/shared-data": "^1.2.0",
"@ban-team/validateur-bal": "^2.17.0",
"@ban-team/validateur-bal": "^2.19.0",
"@etalab/adresses-util": "^0.8.2",
"@etalab/decoupage-administratif": "^4.0.0",
"@etalab/majic": "^0.11.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,10 @@
resolved "https://registry.yarnpkg.com/@ban-team/shared-data/-/shared-data-1.2.0.tgz#0e29e84a00f7df3b17e5821bde1405a2bfa656b5"
integrity sha512-35jz6ITHHufUKxXAfa8ReSMl6lZarnfVBkS++wgHpk27e9K52bXyAHo+n3X331n2mSzoIQXxFK7SEcPob7a5cA==

"@ban-team/validateur-bal@^2.17.0":
version "2.17.0"
resolved "https://registry.yarnpkg.com/@ban-team/validateur-bal/-/validateur-bal-2.17.0.tgz#a43965db72d3f5cc19dc710d209f1543ac9eef91"
integrity sha512-cNCbiVkQ5sCKs4dN6WSxug65F8oceIdiSmnl4OgYZQ4PY3U0xSf05MqfVd6+xXC4pxAZCRvoxtXrhXGJc9f37A==
"@ban-team/validateur-bal@^2.19.0":
version "2.19.0"
resolved "https://registry.yarnpkg.com/@ban-team/validateur-bal/-/validateur-bal-2.19.0.tgz#681ef655077db1486b45426a2ce2930dd034dcc8"
integrity sha512-OIl1BE+MULv/L7ALR6PddNXmqkqwqi31W3SvvK/9GQULZjuMraPXPhHIxpraac1UtbcOzqdSAAKUUfNoqqkQFQ==
dependencies:
"@ban-team/shared-data" "^1.2.0"
"@etalab/project-legal" "^0.6.0"
Expand Down

0 comments on commit c1d207d

Please sign in to comment.