Comparing version 0.2.2 to 0.2.3
@@ -41,2 +41,8 @@ /* | ||
}, | ||
ipv4: function(x) { | ||
check(x, 'must be an IPv4 address').isIPv4(); | ||
}, | ||
ipv6: function(x) { | ||
check(x, 'must be an IPv6 address').isIPv6(); | ||
}, | ||
duration: function(x) { | ||
@@ -49,2 +55,4 @@ check(x, 'must be a positive integer').isInt().min(0); | ||
}; | ||
// alias | ||
types.integer = types.int; | ||
@@ -127,3 +135,3 @@ var converters = {}; | ||
// store declared type | ||
if (!format in types) { | ||
if (!types[format]) { | ||
throw new Error("'" + fullName + "' uses an unknown format type: " + format); | ||
@@ -250,2 +258,3 @@ } | ||
case 'port': | ||
case 'integer': | ||
case 'int': v = parseInt(v, 10); break; | ||
@@ -252,0 +261,0 @@ case 'number': v = parseFloat(v); break; |
@@ -5,3 +5,3 @@ { | ||
"description": "Unruly configuration management for nodejs", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/lloyd/node-convict", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -45,2 +45,10 @@ const should = require('should'); | ||
}, | ||
host2: { | ||
format: 'ipv4', | ||
default: '127.0.0.1' | ||
}, | ||
host3: { | ||
format: 'ipv6', | ||
default: '::1' | ||
}, | ||
port: { | ||
@@ -66,2 +74,6 @@ format: 'port', | ||
}, | ||
int2: { | ||
format: 'integer', | ||
default: 42 | ||
}, | ||
any: { | ||
@@ -83,2 +95,3 @@ format: '*', | ||
}); | ||
}); | ||
@@ -105,2 +118,13 @@ | ||
}); | ||
it('should throw with unknown format', function() { | ||
(function() { | ||
var conf2 = convict({ | ||
foo: { | ||
format: 'unknown', | ||
default: 'bar' | ||
} | ||
}); | ||
}).should.throw(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46993
1298