包详细信息

configuration-processor

benderjs1.2k1.1.1

Configuration processor asserts that input configuration matches predefined configuration schema.

自述文件

Configuration Processor

Configuration processor asserts that input configuration matches predefined configuration schema.

It also provides some basic assertion tools.

Examples

Testing input agains predefined schema

var config = require("configuration-processor"),
    input,
    processed;

input = {
    key1: "key1_value",
    key2: {
        key2n1: false
    }
};

processed = config.assertSchema({
    key1: config.expectStringRegExp(/_value$/),
    key2: config.expectSchema({
        key2n1: config.expectBoolean(),
        key2n2: config.expectBooleanDefault(true)
    })
}, input);

Processed configuration looks like so:

{
    key1: "key1_value",
    key2: {
        key2n1: false,
        key2n2: true
    }
}