@locational/application-registry-validation
v2.4.7
Published
0. Test for empty function! 1. Single function `config_is_valid` or similar 2. Function return `true` to start 3. Deploy to NPM
Downloads
8
Readme
Application Registry Validation
Validate a douma configuration.
Get started
# install
npm i @locational/application-registry-validation
// import
import {validate, errors} from '@locational/application-registry-validation'
API
validate(configuration, ?geodata)
Arguments
configuration (Object): Locational configuration to validate
geodata (Object): Optional, a geodata object
Returns
Boolean : Whether or not the configuration is valid
errors(configuration, ?geodata)
Arguments
configuration (Object): Locational configuration to validate
geodata (Object): Optional, a geodata object
Returns
Array : Objects that describe the errors
Geodata object
If the geodata object is passed to either functions, extra validations that require geodata will be run. If it is not passed, a warning will be printed.
{
"districts": {<geojson feature collection>},
"villages": {<geojson feature collection>}
}
Example
const {validate, errors} = require('@locational/application-registry-validation')
const configuration = {...}
const configuration_valid = validate(configuration)
if (!configuration_valid) {
// invalid configuration
const configuration_errors = errors(configuration)
console.error(configuration_errors)
}
// no problems