6.2.2 • Published 6 years ago
blueconfig-format-with-moment v6.2.2
Blueconfig-format-with-moment
Format 'duration' and 'timestamp' for blueconfig with momentjs.
Install
npm install blueconfig-format-with-momentUsage
An example config.js file:
const blueconfig = require('blueconfig');
blueconfig.addFormat(require('blueconfig-format-with-moment').duration);
blueconfig.addFormat(require('blueconfig-format-with-moment').timestamp);
// Define a schema
var config = blueconfig({
format: {
format: 'duration'
},
format: {
format: 'timestamp'
}
});Validation
This package uses moment.js to validate:
duration- milliseconds or a human readable string (e.g. 3000, "5 days")timestamp- Unix timestamps or date strings recognized by moment.js
Coercion
Blueconfig will automatically coerce strings variables to their proper types when importing them. duration and timestamp are also parse and converted into numbers, though they utilize moment.js for date parsing.