Skip to content

Commit

Permalink
dist: update
Browse files Browse the repository at this point in the history
  • Loading branch information
sagold committed Apr 14, 2024
1 parent 3a2500a commit 9e75444
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/jsonSchemaLibrary.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/lib/draft/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,13 @@ export declare class Draft {
* Returns the json-schema of the given object property or array item.
* e.g. it steps by one key into the data
*
* This helper determines the location of the property within the schema (additional properties, oneOf, ...) and
* returns the correct schema.
* This helper determines the location of the property within the schema (additional properties, oneOf, ...) and
* returns the correct schema.
*
* @param node
* @param key - property-name or array-index
* @param schema - json schema of current data
* @param data - parent of key
* @param [pointer] - pointer to schema and data (parent of key)
* @return Schema or Error if failed resolving key
* @return schema-node containing child schema or error if failed resolving key
*/
step(node: SchemaNode, key: string | number, data: any): SchemaNode | JsonError;
/**
Expand Down
13 changes: 8 additions & 5 deletions dist/module/lib/draft/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy from "../utils/copy";
import { isJsonError } from "../types";
import { isSchemaNode } from "../schemaNode";
export class Draft {
constructor(config, schema) {
Expand Down Expand Up @@ -131,14 +132,13 @@ export class Draft {
* Returns the json-schema of the given object property or array item.
* e.g. it steps by one key into the data
*
* This helper determines the location of the property within the schema (additional properties, oneOf, ...) and
* returns the correct schema.
* This helper determines the location of the property within the schema (additional properties, oneOf, ...) and
* returns the correct schema.
*
* @param node
* @param key - property-name or array-index
* @param schema - json schema of current data
* @param data - parent of key
* @param [pointer] - pointer to schema and data (parent of key)
* @return Schema or Error if failed resolving key
* @return schema-node containing child schema or error if failed resolving key
*/
step(node, key, data) {
return this.config.step(node, key, data);
Expand All @@ -149,6 +149,9 @@ export class Draft {
const inuptNode = data;
return this.config.validate(inuptNode, inputData);
}
if (isJsonError(data)) {
return [data];
}
const node = this.createNode(schema, pointer);
return this.config.validate(node, data);
}
Expand Down
4 changes: 1 addition & 3 deletions dist/module/lib/draft2019/validation/keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function isPropertyEvaluated(schemaNode, propertyName, value) {
// ADDITIONAL-PROPERTIES
if (isObject(schema.additionalProperties)) {
const nextSchema = schema.additionalProperties;
return node.draft.validate(value, nextSchema);
return node.draft.validate(node.next(nextSchema), value);
}
return false;
}
Expand Down Expand Up @@ -168,8 +168,6 @@ const KeywordValidation = {
});
}
});
// const errors = draft.validate(value, { ...schema, unevaluatedItems: undefined }, pointer);
// return errors.map(e => draft.errors.unevaluatedItemsError({ ...e.data }));
}
const errors = [];
value.forEach((item, index) => {
Expand Down
2 changes: 1 addition & 1 deletion dist/module/lib/features/oneOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function resolveOneOf(node, data) {
if (isJsonError(resultNode)) {
return resultNode;
}
let result = flattenArray(draft.validate(oneOfValue, resultNode.schema, pointer));
let result = flattenArray(draft.validate(resultNode, oneOfValue));
result = result.filter(errorOrPromise);
if (result.length > 0) {
errors.push(...result);
Expand Down
3 changes: 2 additions & 1 deletion dist/module/lib/isValid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
* @return if schema does match given value
*/
export default function isValid(draft, value, schema = draft.rootSchema, pointer = "#") {
return draft.validate(value, schema, pointer).length === 0;
const node = draft.createNode(schema, pointer);
return draft.validate(node, value).length === 0;
}
2 changes: 1 addition & 1 deletion dist/module/lib/validateAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function createErrorNotification(onError) {
*/
export default function validateAsync(draft, value, options) {
const { schema, pointer, onError } = { schema: draft.rootSchema, pointer: "#", ...options };
let errors = draft.validate(value, schema, pointer);
let errors = draft.validate(draft.createNode(schema, pointer), value);
if (onError) {
errors = flattenArray(errors);
const notifyError = createErrorNotification(onError);
Expand Down

0 comments on commit 9e75444

Please sign in to comment.