Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

convict

Package Overview
Dependencies
Maintainers
7
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convict - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

18

lib/convict.js

@@ -69,8 +69,14 @@ /**

function validate (instance, schema, errors) {
Object.keys(schema.properties).reduce(function(previousErrors, name) {
function validate (instance, schema, errors,strictValidation) {
Object.keys(instance).reduce(function(previousErrors, name) {
var p = schema.properties[name];
if (strictValidation && !p){
previousErrors.push(new Error("configuration param '"+name+"' not declared in the schema"));
return previousErrors;
}
if (!p)
return;
if (p.properties) {
var kids = instance[name] || {};
validate(kids, p, previousErrors);
validate(kids, p, previousErrors,strictValidation);
} else if (! (typeof p.default === 'undefined' &&

@@ -380,4 +386,6 @@ instance[name] === p.default)) {

},
validate: function() {
var errors = validate(this._instance, this._schema, []);
validate: function(options) {
options = options || {};
options.strict = options.strict || false;
var errors = validate(this._instance, this._schema, [],options.strict);

@@ -384,0 +392,0 @@ if (errors.length) {

@@ -5,3 +5,3 @@ {

"description": "Unruly configuration management for nodejs",
"version": "0.7.0",
"version": "0.8.0",
"homepage": "https://github.com/mozilla/node-convict",

@@ -8,0 +8,0 @@ "repository": {

@@ -8,3 +8,3 @@ # Node-convict

Convict expands on the standard pattern of configuring node.js applications in a way that is more robust and accessible to collaborators, who may have less interest in digging through imperative code in order to inspect or modify settings. By introducting a configuration schema, convict gives project collaborators more **context** on each setting and enables **validation and early failures** for when configuration goes wrong.
Convict expands on the standard pattern of configuring node.js applications in a way that is more robust and accessible to collaborators, who may have less interest in digging through imperative code in order to inspect or modify settings. By introducing a configuration schema, convict gives project collaborators more **context** on each setting and enables **validation and early failures** for when configuration goes wrong.

@@ -110,5 +110,5 @@

### Validation
In order to help detect misconfigurations, convict allows you to define a format for each setting. By defualt, convict checks if the value of the property has the same type (according to `Object.prototype.toString.call`) as the default value specified in the schema. You can define a custom format checking function in the schema by setting the `format` property.
In order to help detect misconfigurations, convict allows you to define a format for each setting. By default, convict checks if the value of the property has the same type (according to `Object.prototype.toString.call`) as the default value specified in the schema. You can define a custom format checking function in the schema by setting the `format` property.
convict provides serveral predefined formats for validation that you can use ([using node-validator](https://github.com/chriso/node-validator#list-of-validation-methods) and [moment.js](http://momentjs.com/)). Most of them are self-explanatory:
convict provides several predefined formats for validation that you can use ([using node-validator](https://github.com/chriso/node-validator#list-of-validation-methods) and [moment.js](http://momentjs.com/)). Most of them are self-explanatory:

@@ -115,0 +115,0 @@ * `*` - any value is valid

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc