Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@mangar2/configuration

1.1.3 • Public • Published

Table of Contents

Meta

  • copyright: Copyright (c) 2020 Volker Böhm

  • author: Volker Böhm

  • license: This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3. It is furnished "as is", without any support, and with no warranty, express or implied, as to its usefulness for any purpose.

sanitize

Sanitizes configuration input and merges it with default values, it not provided in configuration

Parameters

  • configuration Object provided configuration (from configuration file), the function changes this object directly, you may ignore the return value
  • defaultValues Object configuration subset with default values
  • checkInput CheckInput check function to sanitize the configuration. Please set all attributes as mandatory, they get optional by providing default values

Examples

const configuration = { one: 'one', two: 'not two' }
const defaultValues = { two: 'two', three: 3 }
const checkInput = new CheckInput({
type: 'object',
properties: {
one: { type: 'string' },
two: { type: 'string' },
three: { type: 'number' }
},
required: ['one', 'two', 'trhee']
configuration = sanitize(configuration, defaultValues, checkInput)
// configuration is now { one: 'one', two: 'not two', three: 3 }
})

Returns Object merged configuration in provided configuration object

Install

npm i @mangar2/configuration

DownloadsWeekly Downloads

3

Version

1.1.3

License

LGPL-3.0-or-later

Unpacked Size

7.86 kB

Total Files

4

Last publish

Collaborators

  • avatar