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

@exodus/schemasafe

Package Overview
Dependencies
Maintainers
37
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/schemasafe - npm Package Compare versions

Comparing version 1.0.0-beta.3 to 1.0.0-beta.4

2

package.json
{
"name": "@exodus/schemasafe",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "JSON Safe Parser & Schema Validator",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -7,3 +7,3 @@ 'use strict'

const formats = require('./formats')
const functions = require('./scope-functions')
const { toPointer, ...functions } = require('./scope-functions')
const { scopeMethods } = require('./scope-utils')

@@ -39,3 +39,3 @@ const { buildName, types, jsHelpers } = require('./javascript')

const rootMeta = new WeakMap()
const compileSchema = (schema, root, opts, scope, basePathRoot) => {
const compileSchema = (schema, root, opts, scope, basePathRoot = '') => {
const {

@@ -89,3 +89,3 @@ mode = 'default',

if (path.every((part) => part.keyval !== undefined))
return format('%j', functions.toPointer(path.map((part) => part.keyval)))
return format('%j', toPointer(path.map((part) => part.keyval)))

@@ -144,3 +144,3 @@ // Be very careful while refactoring, this code significantly affects includeErrors performance

const error = ({ path = [], prop = current, source, suberr }) => {
const schemaP = functions.toPointer([...schemaPath, ...path])
const schemaP = toPointer([...schemaPath, ...path])
const dataP = includeErrors ? buildPath(prop) : null

@@ -178,3 +178,3 @@ if (includeErrors === true && errors && source) {

const comment = value !== undefined ? ` ${JSON.stringify(value)}` : ''
throw new Error(`${msg}${comment} at ${functions.toPointer(schemaPath)}`)
throw new Error(`${msg}${comment} at ${joinPath(basePathRoot, toPointer(schemaPath))}`)
}

@@ -487,6 +487,6 @@ const enforce = (ok, ...args) => ok || fail(...args)

enforce(value > 0, `Invalid ${multipleOf}:`, value)
if (Number.isInteger(value)) return format('%s %% %d !== 0', name, value)
const [frac, exp] = `${value}.`.split('.')[1].split('e-')
const e = frac.length + (exp ? Number(exp) : 0)
if (Number.isInteger(value * 2 ** e)) return format('%s %% %d !== 0', name, value) // exact
scope.isMultipleOf = functions.isMultipleOf
const [last, exp] = `${value}`.replace(/.*\./, '').split('e-')
const e = last.length + (exp ? Number(exp) : 0)
const args = [name, value, e, Math.round(value * Math.pow(10, e))] // precompute for performance

@@ -919,3 +919,3 @@ return format('!isMultipleOf(%s, %d, 1e%d, %d)', ...args)

if (!stat.type) enforceValidation('type')
if (typeApplicable('array') && stat.items !== Infinity)
if (typeApplicable('array') && stat.items !== Infinity && !(node.maxItems <= stat.items))
enforceValidation(node.items ? 'additionalItems or unevaluatedItems' : 'items rule')

@@ -922,0 +922,0 @@ if (typeApplicable('object') && !stat.properties.includes(true))

@@ -99,4 +99,6 @@ 'use strict'

// Find in additional schemas
if (schemas.has(main))
results.push(...resolveReference(schemas.get(main), additionalSchemas, `#${hash}`))
if (schemas.has(main)) {
const additional = resolveReference(schemas.get(main), additionalSchemas, `#${hash}`)
results.push(...additional.map(([res, rRoot, rPath]) => [res, rRoot, joinPath(main, rPath)]))
}

@@ -103,0 +105,0 @@ // Full refs to additional schemas

@@ -25,2 +25,3 @@ 'use strict'

// Result means that both sets A and B are correct
// type is intersected, lists of known properties are merged
const andDelta = wrapFun((A, B) => ({

@@ -31,3 +32,3 @@ items: Math.max(A.items, B.items),

required: [...A.required, ...B.required],
type: A.type && B.type ? [...new Set([...A.type, ...B.type])] : null,
type: A.type && B.type ? A.type.filter((x) => B.type.includes(x)) : A.type || B.type || null,
fullstring: stringValidated(A) || stringValidated(B),

@@ -58,2 +59,3 @@ dyn: {

// Result means that at least one of sets A and B is correct
// type is merged, lists of known properties are intersected
const orDelta = wrapFun((A, B) => ({

@@ -64,3 +66,3 @@ items: Math.min(A.items, B.items),

required: A.required.filter((x) => B.required.includes(x)),
type: A.type && B.type ? A.type.filter((x) => B.type.includes(x)) : null,
type: A.type && B.type ? [...new Set([...A.type, ...B.type])] : null,
fullstring: stringValidated(A) && stringValidated(B),

@@ -67,0 +69,0 @@ dyn: {

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