Add method for process env validation
mhf-ir opened this issue · 2 comments
mhf-ir commented
I need to know is there any method for preprocess env variable such as.
export TRUSTED_IPS=192.168.1.10,192.168.1.10
nodejs app.js
const schema = {
type: 'object',
required: [ 'TRUSTED_IPS' ],
properties: {
TRUSTED_IPS: {
type: 'array',
items: {
type: 'string',
format: 'ipv4',
},
process(var) {
return var.split(',');
},
default: [],
}
}
}
console.log(process.env.TRUSTED_IPS); // [ '192.168.1.10' , '192.168.1.10' ]
process could be array or json object like:
export SAMPLE='{"foo": { "bar": "baz" }}';
In schema could be:
process: 'Array'
// or
process: 'JSON'
// or user define like above example
mcollina commented
Would you like to send a PR?