Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

another-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

another-json-schema - npm Package Compare versions

Comparing version 3.8.3 to 3.8.4

4

changelog.md

@@ -0,1 +1,5 @@

## 3.8.4/2022-05-31
- add: `Integer` & `Double` types
## 3.8.3/2020-09-15

@@ -2,0 +6,0 @@

18

package.json
{
"name": "another-json-schema",
"version": "3.8.3",
"version": "3.8.4",
"description": "Another JSON Schema, simple & flexible & intuitive.",

@@ -20,4 +20,4 @@ "main": "index.js",

"dependencies": {
"mongodb": "3.6.2",
"validator": "13.1.17"
"mongodb": "4.6.0",
"validator": "13.7.0"
},

@@ -29,12 +29,12 @@ "repository": {

"devDependencies": {
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.22.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"intelli-espower-loader": "1.0.1",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-standard": "4.1.0",
"intelli-espower-loader": "1.1.0",
"istanbul": "^0.4.5",
"mocha": "^8.1.3",
"mocha": "^10.0.0",
"power-assert": "1.6.1"
}
}

@@ -8,2 +8,4 @@ const AJS = require('..')

number: { type: AJS.Types.Number },
integer: { type: AJS.Types.Integer },
double: { type: AJS.Types.Double },
date: { type: AJS.Types.Date },

@@ -40,2 +42,20 @@ buffer: { type: AJS.Types.Buffer },

it('Integer', function () {
let user = UserSchema.validate({ integer: 1.2 })
deepEqual(user.valid, true)
deepEqual(user.result.integer, 1)
user = UserSchema.validate({ integer: 'haha' })
deepEqual(user.valid, false)
})
it('Double', function () {
let user = UserSchema.validate({ double: 1.2 })
deepEqual(user.valid, true)
deepEqual(user.result.double, 1.2)
user = UserSchema.validate({ double: 'haha' })
deepEqual(user.valid, false)
})
it('Date', function () {

@@ -42,0 +62,0 @@ let user = UserSchema.validate({ date: '2018-04-13' })

@@ -38,2 +38,24 @@ const validator = require('validator')

exports.Integer = function Integer (actual, key, parent) {
if (isNaN(parseInt(actual))) {
return false
}
/* istanbul ignore else */
if (key != null) {
parent[key] = parseInt(actual)
}
return true
}
exports.Double = function Double (actual, key, parent) {
if (isNaN(parseFloat(actual))) {
return false
}
/* istanbul ignore else */
if (key != null) {
parent[key] = parseFloat(actual)
}
return true
}
exports.Date = function Date (actual, key, parent) {

@@ -40,0 +62,0 @@ const date = new _Date(actual)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc