New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ban-team/validateur-bal

Package Overview
Dependencies
Maintainers
6
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ban-team/validateur-bal - npm Package Compare versions

Comparing version 2.15.0 to 2.16.0

browser/schema/profiles/1.3-relax.js

4

browser/schema/profiles/index.js
"use strict";
const profiles = {
'1.3-etalab-strict': require('./1.3-etalab-strict'),
'1.3-etalab': require('./1.3-etalab'),
1.3: require('./1.3'),
'1.3-relax': require('./1.3-relax'),
'1.3-strict': require('./1.3-strict'),

@@ -7,0 +7,0 @@ '1.2-strict': require('./1.2-strict'),

@@ -31,4 +31,4 @@ "use strict";

async function parseFile(file, options) {
const parseOptions = options.relaxFieldsDetection ? {
async function parseFile(file, relaxFieldsDetection) {
const parseOptions = relaxFieldsDetection ? {
transformHeader: h => h.toLowerCase().trim()

@@ -130,4 +130,3 @@ } : {}; // Must be a Blob for browser or a Buffer for Node.js

async function prevalidate(file) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
async function prevalidate(file, relaxFieldsDetection) {
const globalErrors = new Set();

@@ -143,3 +142,3 @@ const rowsErrors = new Set();

parsedRows
} = await parseFile(file, options);
} = await parseFile(file, relaxFieldsDetection);

@@ -163,3 +162,3 @@ if (!parseOk) {

globalErrors,
relaxFieldsDetection: options.relaxFieldsDetection
relaxFieldsDetection
});

@@ -256,4 +255,5 @@ const {

let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const profile = options.profile || '1.3-etalab-strict';
const prevalidateResult = await prevalidate(file, options);
const profile = options.profile || '1.3';
const relaxFieldsDetection = options.relaxFieldsDetection === undefined ? options.profile === '1.3-relax' : options.relaxFieldsDetection;
const prevalidateResult = await prevalidate(file, relaxFieldsDetection);
return validateProfile(prevalidateResult, profile);

@@ -260,0 +260,0 @@ }

@@ -21,4 +21,4 @@ const test = require('ava')

test('getErrorLevel', t => {
t.is(getErrorLevel('1.3-etalab', 'voie_nom.trop_court'), 'E')
t.is(getErrorLevel('1.3-etalab', 'voie_nom_bre.trop_court'), 'W')
t.is(getErrorLevel('1.3-relax', 'voie_nom.trop_court'), 'E')
t.is(getErrorLevel('1.3-relax', 'voie_nom_bre.trop_court'), 'W')
})
const profiles = {
'1.3-etalab-strict': require('./1.3-etalab-strict'),
'1.3-etalab': require('./1.3-etalab'),
1.3: require('./1.3'),
'1.3-relax': require('./1.3-relax'),
'1.3-strict': require('./1.3-strict'),

@@ -5,0 +5,0 @@ '1.2-strict': require('./1.2-strict'),

@@ -77,2 +77,80 @@ /* eslint camelcase: off */

test('validate a file with aliases with 1.3-relax', async t => {
const buffer = await readAsBuffer('aliases.csv')
const {fields, notFoundFields} = await validate(buffer, {profile: '1.3-relax'})
const aliasedFields = {
cle_interop: 'cle_intero',
commune_nom: 'commune_no',
commune_insee: 'commune_in',
date_der_maj: 'date_der_m',
lat: 'lat_wgs84',
long: 'long_wgs84',
uid_adresse: 'uid_adress',
x: 'x_l93',
y: 'y_l93'
}
for (const schemaName of Object.keys(aliasedFields)) {
const originalName = aliasedFields[schemaName]
t.truthy(fields.find(f => f.name === originalName && f.schemaName === schemaName))
}
for (const field of [
'cle_interop',
'uid_adresse',
'voie_nom',
'numero',
'suffixe',
'commune_nom',
'position',
'x',
'y',
'long',
'lat',
'source',
'date_der_maj'
]) {
t.true(fields.some(f => f.schemaName === field))
}
t.true(notFoundFields.length === 5)
for (const field of [
'lieudit_complement_nom',
'commune_deleguee_insee',
'commune_deleguee_nom',
'cad_parcelles'
]) {
t.true(notFoundFields.some(f => f.schemaName === field))
}
// Unknown fields
t.true(fields.filter(f => !f.schemaName).length === 0)
})
test('validate a file with aliases / profile relax and relaxFieldsDetection false', async t => {
const buffer = await readAsBuffer('aliases.csv')
const {fields, notFoundFields} = await validate(buffer, {profile: '1.3-relax', relaxFieldsDetection: false})
const unknownFields = fields.filter(f => !f.schemaName)
const knownFields = fields.filter(f => f.schemaName)
const aliasedFields = knownFields.filter(f => f.name !== f.schemaName)
for (const field of [
'voie_nom',
'numero',
'suffixe',
'position',
'source'
]) {
t.truthy(knownFields.find(f => f.schemaName === field))
}
t.is(aliasedFields.length, 0)
t.is(knownFields.length, 5)
t.is(notFoundFields.length, 14)
t.is(unknownFields.length, 9)
})
test('validate a file with aliases / relaxFieldsDetection false', async t => {

@@ -148,5 +226,5 @@ const buffer = await readAsBuffer('aliases.csv')

t.true(globalErrors.includes('rows.empty'))
t.true(!profilesValidation['1.3-etalab'].isValid)
t.true(!profilesValidation['1.3-etalab-strict'].isValid)
t.true(!profilesValidation['1.3-relax'].isValid)
t.true(!profilesValidation['1.3'].isValid)
})

@@ -16,4 +16,4 @@ const bluebird = require('bluebird')

async function parseFile(file, options) {
const parseOptions = options.relaxFieldsDetection
async function parseFile(file, relaxFieldsDetection) {
const parseOptions = relaxFieldsDetection
? {transformHeader: h => h.toLowerCase().trim()}

@@ -92,7 +92,7 @@ : {}

async function prevalidate(file, options = {}) {
async function prevalidate(file, relaxFieldsDetection) {
const globalErrors = new Set()
const rowsErrors = new Set()
const {encoding, linebreak, delimiter, originalFields, parseOk, parseErrors, parsedRows} = await parseFile(file, options)
const {encoding, linebreak, delimiter, originalFields, parseOk, parseErrors, parsedRows} = await parseFile(file, relaxFieldsDetection)

@@ -103,3 +103,3 @@ if (!parseOk) {

const {fields, notFoundFields} = computeFields(originalFields, {globalErrors, relaxFieldsDetection: options.relaxFieldsDetection})
const {fields, notFoundFields} = computeFields(originalFields, {globalErrors, relaxFieldsDetection})
const {rows} = await computeRows(parsedRows, {fields, rowsErrors})

@@ -183,4 +183,5 @@ const fileValidation = validateFile({linebreak, encoding, delimiter}, {globalErrors})

async function validate(file, options = {}) {
const profile = options.profile || '1.3-etalab-strict'
const prevalidateResult = await prevalidate(file, options)
const profile = options.profile || '1.3'
const relaxFieldsDetection = (options.relaxFieldsDetection === undefined) ? options.profile === '1.3-relax' : options.relaxFieldsDetection
const prevalidateResult = await prevalidate(file, relaxFieldsDetection)
return validateProfile(prevalidateResult, profile)

@@ -187,0 +188,0 @@ }

{
"name": "@ban-team/validateur-bal",
"version": "2.15.0",
"version": "2.16.0",
"description": "Validateur de référence pour le format BAL",

@@ -5,0 +5,0 @@ "repository": "https://github.com/BaseAdresseNationale/validateur-bal",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc