Skip to content

Commit

Permalink
be: bis, nn: validate: return compact as result of compact func
Browse files Browse the repository at this point in the history
  • Loading branch information
okkainen committed Oct 26, 2022
1 parent 663a970 commit f6283fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
23 changes: 11 additions & 12 deletions src/be/bis.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ function toDob(firstSix) {
return dobArray.map((n) => `${n}`.padStart(2, '0')).join('')
}

export function compact(input) {
const [value, err] = clean(input)

if (err) {
throw err
}

return value
}

const impl = {
name: 'Belgian Number for Foreigners',
localName: 'Numéro BIS',
abbreviation: 'BIS',
compact(input) {
const [value, err] = clean(input)

if (err) {
throw err
}

return value
},
format(input) {
const [value] = clean(input)
return value
Expand All @@ -74,13 +73,13 @@ const impl = {

return {
isValid: true,
compact,
compact: number,
isIndividual: true,
isCompany: false,
}
},
}

export const {
name, localName, abbreviation, validate, format,
name, localName, abbreviation, compact, validate, format,
} = impl
23 changes: 11 additions & 12 deletions src/be/nn.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ function clean(input) {
return strings.cleanUnicode(input, ' -.')
}

export function compact(input) {
const [value, err] = clean(input)

if (err) {
throw err
}

return value
}

const impl = {
name: 'Belgian National Number',
localName: 'Numéro National',
abbreviation: 'NN, RN',
compact(input) {
const [value, err] = clean(input)

if (err) {
throw err
}

return value
},
format(input) {
const [value] = clean(input)
return value
Expand All @@ -54,13 +53,13 @@ const impl = {

return {
isValid: true,
compact,
compact: number,
isIndividual: true,
isCompany: false,
}
},
}

export const {
name, localName, abbreviation, validate, format,
name, localName, abbreviation, compact, validate, format,
} = impl

0 comments on commit f6283fc

Please sign in to comment.