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

is-my-json-valid

Package Overview
Dependencies
Maintainers
4
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-my-json-valid - npm Package Compare versions

Comparing version 2.13.0 to 2.13.1

18

index.js

@@ -100,2 +100,14 @@ var genobj = require('generate-object-property')

var isMultipleOf = function(name, multipleOf) {
var res;
var factor = ((multipleOf | 0) !== multipleOf) ? Math.pow(10, multipleOf.toString().split('.').pop().length) : 1
if (factor > 1) {
var factorName = ((name | 0) !== name) ? Math.pow(10, name.toString().split('.').pop().length) : 1
if (factorName > factor) res = true
else res = Math.round(factor * name) % (factor * multipleOf)
}
else res = name % multipleOf;
return !res;
}
var toType = function(node) {

@@ -107,3 +119,3 @@ return node.type

var fmts = opts ? xtend(formats, opts.formats) : formats
var scope = {unique:unique, formats:fmts}
var scope = {unique:unique, formats:fmts, isMultipleOf:isMultipleOf}
var verbose = opts ? !!opts.verbose : false;

@@ -438,5 +450,3 @@ var greedy = opts && opts.greedy !== undefined ?

var factor = ((node.multipleOf | 0) !== node.multipleOf) ? Math.pow(10, node.multipleOf.toString().split('.').pop().length) : 1
if (factor > 1) validate('if ((%d*%s) % %d) {', factor, name, factor*node.multipleOf)
else validate('if (%s % %d) {', name, node.multipleOf)
validate('if (!isMultipleOf(%s, %d)) {', name, node.multipleOf)

@@ -443,0 +453,0 @@ error('has a remainder')

{
"name": "is-my-json-valid",
"version": "2.13.0",
"version": "2.13.1",
"description": "A JSONSchema validator that uses code generation to be extremely fast",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,3 +43,3 @@ # is-my-json-valid

``` js
var validate = validate('{"type": ... }')
var validate = validator('{"type": ... }')
```

@@ -46,0 +46,0 @@

@@ -59,3 +59,39 @@ [

]
},
{
"description": "by decimal number where floating point precision is wrong",
"schema": {"multipleOf": 0.01},
"tests": [
{
"description": "Number 2 is multiple of 0.01",
"data": 2,
"valid": true
},
{
"description": "Number 2.1 is multiple of 0.01",
"data": 2.1,
"valid": true
},
{
"description": "Number 2.2 is multiple of 0.01",
"data": 2.2,
"valid": true
},
{
"description": "Number 2.3 is multiple of 0.01",
"data": 2.3,
"valid": true
},
{
"description": "Number 2.4 is multiple of 0.01",
"data": 2.4,
"valid": true
},
{
"description": "Number 1.211 is not multiple of 0.01",
"data": 1.211,
"valid": false
}
]
}
]
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