Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "formconv", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A utility function to convert and validate form post data, and filter secure data from data base object", | ||
@@ -5,0 +5,0 @@ "main": "scheme.js", |
@@ -39,4 +39,4 @@ /** | ||
var typeType = typeof type; | ||
if(type != 'int' && type != String && type != Number && type != Date) { | ||
throw new Error('wront type ' + type + ' for field ' + field); | ||
if(type != 'int' && type != String && type != Number && type != Date && type != Array) { | ||
throw new Error('wrong type ' + type + ' for field ' + field); | ||
} | ||
@@ -70,2 +70,5 @@ } | ||
break; | ||
case Array: | ||
if(value instanceof Array) return value | ||
return null | ||
default: | ||
@@ -72,0 +75,0 @@ throw new Error('not support type '+ fieldDefine.type) |
@@ -12,3 +12,4 @@ var expect = require('expect.js') | ||
reqString: {type: String, required: true}, | ||
reqNumber: {type: Number, required: true} | ||
reqNumber: {type: Number, required: true}, | ||
array: Array | ||
}) | ||
@@ -24,2 +25,3 @@ | ||
reqNumber: '50', | ||
array: [], | ||
nonExist: 'not exists' | ||
@@ -35,2 +37,3 @@ } | ||
expect(obj.reqDate).to.be.a(Date) | ||
expect(obj.array).to.be.a(Array) | ||
expect(obj.reqNumber).to.be.a('number') | ||
@@ -47,2 +50,3 @@ }) | ||
reqNumber: 50, | ||
array: [], | ||
nonExist: 'not exists' | ||
@@ -57,2 +61,3 @@ } | ||
expect(obj.reqString).to.be.ok() | ||
expect(obj.array).to.be.a(Array) | ||
expect(obj.nonExist).to.be(undefined) | ||
@@ -59,0 +64,0 @@ expect(obj.password).to.be(undefined) |
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
7109
178