Socket
Socket
Sign inDemoInstall

formconv

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"name": "formconv",
"version": "0.1.1",
"version": "0.1.2",
"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",

@@ -60,3 +60,7 @@ /**

case Number:
return Number(value);
var value = Number(value);
if(value == NaN) {
throw new Error();
}
return value;
case Boolean:

@@ -79,2 +83,8 @@ return (value == 'true' || value == true || value == 1 || value == '1' || value == 'yes')

case Object:
if(typeof value == 'string') {
if(value == '') return null
if(value[0] == '{' && value[value.length - 1] == '}') {
return JSON.parse(value)
}
}
return value

@@ -81,0 +91,0 @@ default:

@@ -15,2 +15,3 @@ var expect = require('expect.js')

reqNumber: {type: Number, required: true},
obj1: {type:Object, private: true},
array: Array,

@@ -31,2 +32,3 @@ array1: Array,

reqNumber: '50',
obj1: '{"hello":"world"}',
array: [1,2,3],

@@ -45,2 +47,3 @@ array1: '[1, 2, 3]',

expect(obj.reqDate).to.be.a(Date)
expect(obj.obj1.hello).to.be('world')
expect(obj.array).to.be.a(Array)

@@ -75,2 +78,3 @@ expect(obj.array1).to.be.a(Array)

expect(obj.reqString).to.be.ok()
expect(obj.obj1).to.be(undefined)
expect(obj.array).to.be.a(Array)

@@ -77,0 +81,0 @@ expect(obj.nonExist).to.be(undefined)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc