Comparing version 4.4.0 to 4.4.1
@@ -8,2 +8,12 @@ # Change Log | ||
## [4.4.1] - 2018-12-15 | ||
### Fixed | ||
- Fix README for addFormats #268, #275 (Walter Rumsby @wrumsby, Sebastian Yandun | ||
@svyandun, Eray Hanoglu @erayhanoglu, Marc-Aurèle Darche @madarche) | ||
### Changed | ||
- Update deps (yargs-parser, validator) (Marc-Aurèle Darche @madarche) | ||
## [4.4.0] - 2018-09-22 | ||
@@ -10,0 +20,0 @@ ### Fixed |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"license": "Apache-2.0", | ||
@@ -48,4 +48,4 @@ "homepage": "https://github.com/mozilla/node-convict", | ||
"moment": "2.22.2", | ||
"validator": "10.4.0", | ||
"yargs-parser": "10.1.0" | ||
"validator": "10.8.0", | ||
"yargs-parser": "11.0.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "devDependencies": { |
@@ -317,10 +317,52 @@ # Node-convict | ||
### convict.addFormat(format) | ||
### convict.addFormat(format) or convict.addFormat(name, validate, coerce) | ||
Adds a new custom format. | ||
Adds a new custom format, `format` being an object, see example below. | ||
### config.addFormats(formatArray) | ||
```javascript | ||
convict.addFormat({ | ||
name: 'float-percent', | ||
validate: function(val) { | ||
if (val !== 0 && (!val || val > 1 || val < 0)) { | ||
throw new Error('must be a float between 0 and 1, inclusive'); | ||
} | ||
}, | ||
coerce: function(val) { | ||
return parseFloat(val, 10); | ||
} | ||
}); | ||
``` | ||
Adds new custom formats. | ||
### convict.addFormats(formats) | ||
Adds new custom formats, `formats` being an object whose keys are the new custom | ||
format names, see example below. | ||
```javascript | ||
convict.addFormats({ | ||
prime: { | ||
validate: function(val) { | ||
function isPrime(n) { | ||
if (n <= 1) return false; // zero and one are not prime | ||
for (let i=2; i*i <= n; i++) { | ||
if (n % i === 0) return false; | ||
} | ||
return true; | ||
} | ||
if (!isPrime(val)) throw new Error('must be a prime number'); | ||
}, | ||
coerce: function(val) { | ||
return parseInt(val, 10); | ||
} | ||
}, | ||
'hex-string': { | ||
validate: function(val) { | ||
if (/^[0-9a-fA-F]+$/.test(val)) { | ||
throw new Error('must be a hexidecimal string'); | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
### config.get(name) | ||
@@ -327,0 +369,0 @@ |
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
53939
495
+ Addedcamelcase@5.3.1(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedvalidator@10.8.0(transitive)
+ Addedyargs-parser@11.0.0(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedvalidator@10.4.0(transitive)
- Removedyargs-parser@10.1.0(transitive)
Updatedvalidator@10.8.0
Updatedyargs-parser@11.0.0