whitelister
Advanced tools
Comparing version 0.0.5 to 0.1.0-beta
@@ -104,8 +104,12 @@ const { ArgumentError, FieldError, WhitelistError } = require('./errors'); | ||
} else { | ||
const filter = has.call(filters, rule.type) ? filters[rule.type] : rule.filterWith; | ||
if (has.call(rule, 'preTransform') && isFunc(rule.preTransform)) { | ||
val = rule.preTransform(val); | ||
val = rule.preTransform(val, properName); | ||
} | ||
val = filter(rule, val, properName); | ||
if (!isFunc(rule.filterWith)) { | ||
val = filters[rule.type](rule, val, properName); | ||
} else if (!rule.filterWith(val, properName)) { | ||
throw new FieldError(properName, 'is invalid'); | ||
} | ||
const validValue = acceptedValues => | ||
@@ -121,8 +125,4 @@ acceptedValues.some((acceptedValue) => { | ||
if (isFunc(rule.filterWith) && !rule.filterWith(val)) { | ||
throw new FieldError(properName, 'is invalid'); | ||
} | ||
filteredParams[name] = (has.call(rule, 'postTransform') && isFunc(rule.postTransform)) ? | ||
rule.postTransform(val) : val; | ||
rule.postTransform(val, properName) : val; | ||
} | ||
@@ -129,0 +129,0 @@ } else if (isDefined(rule.default)) { |
{ | ||
"name": "whitelister", | ||
"version": "0.0.5", | ||
"version": "0.1.0-beta", | ||
"description": "Simple, basic filtering and validation tool for Node.js.", | ||
"main": "whitelister.js", | ||
"main": "./whitelister.js", | ||
"repository": { | ||
@@ -11,2 +11,6 @@ "url": "https://github.com/SpireTeam/whitelister", | ||
"scripts": { | ||
"build": "yarn run build:main && yarn run build:min", | ||
"build:main": "./node_modules/.bin/webpack --config webpack.config.js", | ||
"build:min": "./node_modules/.bin/webpack --config webpack.min.js", | ||
"prepublish": "yarn run test && yarn run build", | ||
"test": "NODE_ENV=test mocha --require mocha-clean --timeout=10000", | ||
@@ -39,2 +43,3 @@ "lint": "eslint ." | ||
"whitelister.js", | ||
"dist/*.js", | ||
"lib/*.js" | ||
@@ -45,3 +50,6 @@ ], | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^7.2.3", | ||
"babel-loader": "^7.1.2", | ||
"babel-preset-env": "^1.6.1", | ||
"chai": "^3.5.0", | ||
@@ -56,4 +64,5 @@ "chai-as-promised": "^7.1.1", | ||
"mocha": "^2.4.5", | ||
"mocha-clean": "^1.0.0" | ||
"mocha-clean": "^1.0.0", | ||
"webpack": "^3.8.1" | ||
} | ||
} |
@@ -5,2 +5,4 @@ # Whitelister | ||
[![Build Status](https://travis-ci.org/SpireTeam/whitelister.svg?branch=master)](https://travis-ci.org/SpireTeam/whitelister) | ||
## Quick Start | ||
@@ -38,4 +40,9 @@ | ||
### v0.0.5 | ||
#### Oct. 25, 2017 | ||
* Ignore non-required properties with `undefined` values | ||
* Treat external errors differently than internal errors | ||
### v0.0.4 | ||
#### Oct. 16, 2017 | ||
* Ensure that `type` is treated like other `attributes` |
43069
9
830
46
15