input-filter
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -5,2 +5,3 @@ export default { | ||
Bool: require('./src/filter/Bool.js'), | ||
StringTrim: require('./src/filter/StringTrim.js'), | ||
@@ -7,0 +8,0 @@ Float: require('./src/filter/Float.js'), |
{ | ||
"name": "input-filter", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "InputFilter js implementation", | ||
"main": "main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha --compilers js:babel/register" | ||
}, | ||
@@ -29,5 +29,9 @@ "repository": { | ||
"babelify": "^6.0.2", | ||
"chai": "^2.2.0", | ||
"gulp": "^3.8.11", | ||
"gulp-uglify": "^1.2.0" | ||
}, | ||
"dependencies": { | ||
"moment": "^2.10.2" | ||
} | ||
} |
@@ -5,3 +5,7 @@ | ||
filter(value) { | ||
return parseFloat(value) | ||
let newValue = parseFloat(value) | ||
if (isNaN(newValue)) { | ||
throw new Error(`${value} is not a Number`) | ||
} | ||
return newValue | ||
} | ||
@@ -8,0 +12,0 @@ } |
@@ -5,3 +5,7 @@ | ||
filter(value) { | ||
return parseInt(value) | ||
let newValue = parseInt(value) | ||
if (isNaN(newValue)) { | ||
throw new Error(`${value} is not a Number`) | ||
} | ||
return newValue | ||
} | ||
@@ -8,0 +12,0 @@ } |
@@ -8,1 +8,3 @@ | ||
} | ||
export default StringTrim |
@@ -24,5 +24,2 @@ import FilterChain from './FilterChain.js' | ||
setValue(value) { | ||
if (value === this.value) { | ||
return this | ||
} | ||
this.value = this.filterChain.filter(value) | ||
@@ -29,0 +26,0 @@ |
@@ -8,5 +8,11 @@ | ||
this.valid = null | ||
this.rawData = {} | ||
this.data = {} | ||
this.init() | ||
} | ||
init() { | ||
} | ||
add(input) { | ||
@@ -19,3 +25,3 @@ this.inputs[input.name] = input | ||
setData(data) { | ||
this.data = data | ||
this.rawData = data | ||
this.reset() | ||
@@ -26,3 +32,8 @@ | ||
getData() { | ||
return this.data | ||
} | ||
reset() { | ||
this.data = {} | ||
this.promise = null | ||
@@ -40,7 +51,7 @@ this.messages = {} | ||
if (this.inputs.hasOwnProperty(name)) { | ||
let value = this.data[name] | ||
let input = this.inputs[name] | ||
let promise = input.setValue(value).isValid(this.data) | ||
promise.then( | ||
() => {}, | ||
input.setValue(this.data[name]) | ||
this.data[name] = input.getValue() | ||
let promise = input.isValid(this.data) | ||
promise.catch( | ||
(messages) => { | ||
@@ -71,4 +82,8 @@ if (!this.messages[name]) { | ||
} | ||
getValue(key) { | ||
return this.inputs[key].getValue() | ||
} | ||
} | ||
export default InputFilter |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
12833
23
378
2
1
5
+ Addedmoment@^2.10.2
+ Addedmoment@2.30.1(transitive)