json-schema-library
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -0,1 +1,2 @@ | ||
const gp = require("gson-pointer"); | ||
const emptyObject = {}; | ||
@@ -18,3 +19,3 @@ | ||
function getSchema(core, schema, data, pointer = "#") { | ||
const frags = pointer.replace(/^[#\/]+/, "").split("/"); | ||
const frags = gp.split(pointer); | ||
return _get(core, schema, frags, pointer, data); | ||
@@ -21,0 +22,0 @@ } |
@@ -17,3 +17,3 @@ const gp = require("gson-pointer"); | ||
const targetSchema = getTargetSchema(schema.$ref, rootSchema, rootSchema); | ||
let reference = gp.get(targetSchema, decodeURIComponent(target)); | ||
let reference = gp.get(targetSchema, target); | ||
reference = resolveRef(reference, targetSchema); // resolve ref until completely resolved | ||
@@ -20,0 +20,0 @@ |
@@ -21,3 +21,3 @@ const gp = require("gson-pointer"); | ||
const targetSchema = getTargetSchema(schema.$ref, rootSchema, rootSchema); | ||
let reference = gp.get(targetSchema, decodeURIComponent(target)); | ||
let reference = gp.get(targetSchema, target); | ||
reference = resolveRef(reference, targetSchema); // resolve ref until completely resolved | ||
@@ -24,0 +24,0 @@ |
const getSchema = require("./getSchema"); | ||
const Core = require("./cores/JsonEditor"); | ||
const gp = require("gson-pointer"); | ||
const getParentPointer = require("gson-pointer/lib/common").getParentPointer; | ||
const getLastProperty = require("gson-pointer/lib/common").getLastProperty; | ||
@@ -47,3 +45,3 @@ | ||
const parentPointer = getParentPointer(pointer); | ||
const parentPointer = gp.join(pointer, ".."); | ||
let parentSchema = this.cache[parentPointer]; | ||
@@ -59,3 +57,3 @@ if (parentSchema == null) { | ||
// step from parent to child | ||
const key = getLastProperty(pointer); | ||
const key = gp.split(pointer).pop(); | ||
let schema = getSchema(this.core, this.cache[parentPointer], gp.get(this.data, parentPointer), key); | ||
@@ -62,0 +60,0 @@ schema = copy(schema); |
const getTypeOf = require("../getTypeOf"); | ||
const puny = require("punycode"); | ||
const ucs2decode = require("../utils/punycode.ucs2decode"); | ||
const settings = require("../config/settings"); | ||
@@ -8,2 +8,3 @@ const FPP = settings.floatingPointPrecision; | ||
const KeywordValidation = { | ||
additionalProperties: (core, schema, value, pointer) => { | ||
@@ -204,3 +205,3 @@ if (schema.additionalProperties === true || schema.additionalProperties == null) { | ||
} | ||
const lengthOfString = puny.ucs2.decode(value).length; | ||
const lengthOfString = ucs2decode(value).length; | ||
if (schema.maxLength < lengthOfString) { | ||
@@ -226,3 +227,3 @@ return core.errors.maxLengthError({ maxLength: schema.maxLength, length: lengthOfString, pointer }); | ||
} | ||
const lengthOfString = puny.ucs2.decode(value).length; | ||
const lengthOfString = ucs2decode(value).length; | ||
if (schema.minLength > lengthOfString) { | ||
@@ -229,0 +230,0 @@ return core.errors.minLengthError({ minLength: schema.minLength, length: lengthOfString, pointer }); |
{ | ||
"name": "json-schema-library", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation", | ||
@@ -12,3 +12,4 @@ "main": "index.js", | ||
"tdd": "watch \"npm run test-unit\" lib/ test/", | ||
"coverage": "nyc npm run test --reporter=lcov" | ||
"coverage": "nyc npm run test --reporter=lcov", | ||
"analyze": "NODE_ENV=production webpack --json | webpack-bundle-size-analyzer" | ||
}, | ||
@@ -38,7 +39,7 @@ "pre-push": [ | ||
"watch": "^1.0.1", | ||
"webpack": "^3.8.1" | ||
"webpack": "^3.8.1", | ||
"webpack-bundle-size-analyzer": "^2.7.0" | ||
}, | ||
"dependencies": { | ||
"gson-pointer": "^2.2.0", | ||
"punycode": "^2.1.0", | ||
"gson-pointer": "^3.2.1", | ||
"valid-url": "^1.0.9" | ||
@@ -45,0 +46,0 @@ }, |
@@ -14,3 +14,3 @@ # json-schema-library | ||
- This package is tested on node v6.9.1 and in latest Browsers. | ||
- This library currently supports all draft4 features | ||
- This library currently supports all draft4 features (@see [benchmark](https://github.com/sagold/json-schema-benchmark)) | ||
@@ -84,3 +84,4 @@ | ||
```js | ||
const core = new require("json-schema-library").core.draft04(rootSchema), | ||
const Core = require("json-schema-library").cores.Draft04; | ||
const core = new Core(rootSchema); | ||
const targetSchema = core.getSchema(rootSchema, '#/path/to/target', rootData); | ||
@@ -100,3 +101,4 @@ ``` | ||
```js | ||
const core = new require("json-schema-library").core.draft04(rootSchema), | ||
const Core = require("json-schema-library").cores.Draft04; | ||
const core = new Core(rootSchema); | ||
const targetSchema = getSchema(core, rootSchema, '#/path/to/target', rootData); | ||
@@ -148,3 +150,2 @@ ``` | ||
const Core = require("json-schema-library").cores.Draft04; | ||
const validateAsync = require("json-schema-library").validateAsync; | ||
const core = new Core(rootSchema); | ||
@@ -151,0 +152,0 @@ // signature: Core, Schema, Data, [Pointer], [onErrorCallback] : Promise |
17
TASKS.md
# Tasks | ||
## 2018 | ||
- [ ] draft06 support | ||
### possibly | ||
- [ ] improve performance | ||
- [ ] iterate schema: resolve $ref and definitions | ||
## 2017 | ||
- [ ] iterate schema: resolve $ref and definitions | ||
- [ ] profile performance | ||
- [ ] -- Change -- addSchema to be setup per instance | ||
- [ ] -- Refactor -- move type validation as keyword to validation/keywords | ||
- [ ] -- Refactor -- Use addValidation to setup base validation mappings? | ||
- [ ] -- Features -- Helper to find a json- and json-schema-pointer | ||
- [ ] -- Refactor -- consider unifying keyword.oneOf and step.oneof (Object, Array) | ||
- [~] -- Features -- Improve validation maps to add & hook (!) custom entries (WIP, Add tests) | ||
@@ -32,6 +40,3 @@ - [✓] -- Fix -- Return all errors in oneOf-validation | ||
### unsupported optional draft04 features | ||
- [x] -- bignum (optional) | ||
## 16/12 | ||
@@ -38,0 +43,0 @@ |
897492
2
87
6904
269
11
+ Addedgson-pointer@3.4.3(transitive)
- Removedpunycode@^2.1.0
- Removedgson-pointer@2.2.0(transitive)
- Removedpunycode@2.3.1(transitive)
Updatedgson-pointer@^3.2.1