mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
fix profile and profile validation 🐛
This commit is contained in:
parent
a10e9487bd
commit
551d2b8215
2 changed files with 7 additions and 2 deletions
|
@ -7,7 +7,7 @@ const types = {
|
|||
transformReqBody: 'function',
|
||||
transformJourneysQuery: 'function',
|
||||
|
||||
products: 'object',
|
||||
products: 'array',
|
||||
|
||||
parseDateTime: 'function',
|
||||
parseDeparture: 'function',
|
||||
|
@ -36,7 +36,11 @@ const types = {
|
|||
const validateProfile = (profile) => {
|
||||
for (let key of Object.keys(types)) {
|
||||
const type = types[key]
|
||||
if (type !== typeof profile[key]) {
|
||||
if (type === 'array') {
|
||||
if (!Array.isArray(profile[key])) {
|
||||
throw new Error(`profile.${key} must be an array.`)
|
||||
}
|
||||
} else if (type !== typeof profile[key]) {
|
||||
throw new Error(`profile.${key} must be a ${type}.`)
|
||||
}
|
||||
if (type === 'object' && profile[key] === null) {
|
||||
|
|
|
@ -69,6 +69,7 @@ const insaProfile = {
|
|||
endpoint: 'http://reiseauskunft.insa.de/bin/mgate.exe',
|
||||
transformReqBody,
|
||||
|
||||
products: products.allProducts,
|
||||
parseProducts: createParseBitmask(products.allProducts, defaultProducts),
|
||||
formatProducts,
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue