Methods
-
parseConfig( config, schema ) → {object}
-
Description
Check a (user) provided config object against a (developer) pre-defined schema object.Parameters
Name Type Description config
object The actual config object you provide. Property-value pairs describe the config options. Can be recursive. schema
object The schema object the config object must adhere to. Name Type Description key
object | string Each key describes a config property. Can be object notation or shorthand string notation. See example below. Returns
Examples
parseConfig({ aString: "abc", aNumber: 123, }, { aString: {type: "string", required: true}, aNumber: "number*" someDefault: {type: "number", default: 456} });
{schemaProp: "type:defaultVal*"} //an asterisk at the end denotes a required property
parseConfig({ version: "1.2.3", project: { name: "cats", author: "Joe Kerr" } }, { version: "string:0.0.1", project: { name: "string", author: "string:Joe Kerr", } });
{schemaProp: {type: null}}
Throws
Details