another-json-schema
Advanced tools
Comparing version 3.8.3 to 3.8.4
@@ -0,1 +1,5 @@ | ||
## 3.8.4/2022-05-31 | ||
- add: `Integer` & `Double` types | ||
## 3.8.3/2020-09-15 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"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' }) |
22
Types.js
@@ -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) |
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
58544
1514
+ Added@types/node@22.10.1(transitive)
+ Added@types/webidl-conversions@7.0.3(transitive)
+ Added@types/whatwg-url@8.2.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbson@4.7.2(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addeddenque@2.1.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedmongodb@4.6.0(transitive)
+ Addedmongodb-connection-string-url@2.6.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedtr46@3.0.0(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedvalidator@13.7.0(transitive)
+ Addedwebidl-conversions@7.0.0(transitive)
+ Addedwhatwg-url@11.0.0(transitive)
- Removedbl@2.2.1(transitive)
- Removedbson@1.1.6(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddenque@1.5.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedmongodb@3.6.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedrequire_optional@1.0.1(transitive)
- Removedresolve-from@2.0.0(transitive)
- Removedsafe-buffer@5.1.25.2.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvalidator@13.1.17(transitive)
Updatedmongodb@4.6.0
Updatedvalidator@13.7.0