Skip to content

Commit

Permalink
Bump version to 2.7.1 and update dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
bhch committed Mar 24, 2023
1 parent 8f33985 commit 964564b
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 26 deletions.
40 changes: 32 additions & 8 deletions dist/react-json-form.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function getBlankArray(schema, getRef) {
let type = normalizeKeyword(schema.items.type);

if (!type) {
if (schema.items.hasOwnProperty['oneOf']) type = schema.items.oneOf[0];else if (schema.items.hasOwnProperty['anyOf']) type = schema.items.anyOf[0];else if (schema.items.hasOwnProperty['allOf']) type = schema.items.allOf[0];
if (Array.isArray(schema.items['oneOf'])) type = getSchemaType(schema.items.oneOf[0]);else if (Array.isArray(schema.items['anyOf'])) type = getSchemaType(schema.items.anyOf[0]);else if (Array.isArray(schema.items['allOf'])) type = getSchemaType(schema.items.allOf[0]);
}

if (type === 'array') {
Expand All @@ -251,6 +251,14 @@ function getBlankArray(schema, getRef) {
} else if (type === 'object') {
while (items.length < minItems) items.push(getBlankObject(schema.items, getRef));

return items;
} else if (type === 'oneOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
} else if (type === 'anyOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
}

Expand Down Expand Up @@ -3288,23 +3296,26 @@ function validateArray(schema) {
} else {
if (!schema.items.hasOwnProperty('oneOf') && !schema.items.hasOwnProperty('anyOf') && !schema.items.hasOwnProperty('allOf')) return {
isValid: false,
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf' or 'allOf'"
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"
};
}

if (schema.hasOwnProperty('oneOf')) {
if (schema.items.hasOwnProperty('oneOf')) {
validation = validateOneOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('anyOf')) {
if (schema.items.hasOwnProperty('anyOf')) {
validation = validateAnyOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('allOf')) {
validation = validateAllOf(schema.items);
if (!validation.isValid) return validation;
if (schema.items.hasOwnProperty('allOf')) {
// we don't support allOf inside array yet
return {
isValid: false,
msg: "Currently, 'allOf' inside array items is not supported"
};
}

return {
Expand Down Expand Up @@ -3366,13 +3377,18 @@ function validateSubschemas(schema, keyword) {
keyword: one of 'oneOf' or 'anyOf' or 'allOf'
Validation:
1. Must be an array
2. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
2. Must have at least one subschema
3. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
*/
let subschemas = schema[keyword];
if (!Array.isArray(subschemas)) return {
isValid: false,
msg: "'" + keyword + "' property must be an array"
};
if (!subschemas.length) return {
isValid: false,
msg: "'" + keyword + "' must contain at least one subschema"
};

for (let i = 0; i < subschemas.length; i++) {
let subschema = subschemas[i];
Expand Down Expand Up @@ -3758,6 +3774,14 @@ function DataValidator(schema) {

let next_validator = this.getValidator(next_type);

if (!next_validator) {
if (next_schema.hasOwnProperty('oneOf')) {
next_validator = this.validateOneOf;
} else if (next_schema.hasOwnProperty('anyOf')) {
next_validator = this.validateAnyOf;
} else if (next_schema.hasOwnProperty('anyOf')) ;
}

if (next_validator) {
for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i]));
} else this.addError(coords, 'Unsupported type "' + next_type + '" for array items.');
Expand Down
2 changes: 1 addition & 1 deletion dist/react-json-form.js

Large diffs are not rendered by default.

40 changes: 32 additions & 8 deletions dist/react-json-form.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function getBlankArray(schema, getRef) {
let type = normalizeKeyword(schema.items.type);

if (!type) {
if (schema.items.hasOwnProperty['oneOf']) type = schema.items.oneOf[0];else if (schema.items.hasOwnProperty['anyOf']) type = schema.items.anyOf[0];else if (schema.items.hasOwnProperty['allOf']) type = schema.items.allOf[0];
if (Array.isArray(schema.items['oneOf'])) type = getSchemaType(schema.items.oneOf[0]);else if (Array.isArray(schema.items['anyOf'])) type = getSchemaType(schema.items.anyOf[0]);else if (Array.isArray(schema.items['allOf'])) type = getSchemaType(schema.items.allOf[0]);
}

if (type === 'array') {
Expand All @@ -245,6 +245,14 @@ function getBlankArray(schema, getRef) {
} else if (type === 'object') {
while (items.length < minItems) items.push(getBlankObject(schema.items, getRef));

return items;
} else if (type === 'oneOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
} else if (type === 'anyOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
}

Expand Down Expand Up @@ -3282,23 +3290,26 @@ function validateArray(schema) {
} else {
if (!schema.items.hasOwnProperty('oneOf') && !schema.items.hasOwnProperty('anyOf') && !schema.items.hasOwnProperty('allOf')) return {
isValid: false,
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf' or 'allOf'"
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"
};
}

if (schema.hasOwnProperty('oneOf')) {
if (schema.items.hasOwnProperty('oneOf')) {
validation = validateOneOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('anyOf')) {
if (schema.items.hasOwnProperty('anyOf')) {
validation = validateAnyOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('allOf')) {
validation = validateAllOf(schema.items);
if (!validation.isValid) return validation;
if (schema.items.hasOwnProperty('allOf')) {
// we don't support allOf inside array yet
return {
isValid: false,
msg: "Currently, 'allOf' inside array items is not supported"
};
}

return {
Expand Down Expand Up @@ -3360,13 +3371,18 @@ function validateSubschemas(schema, keyword) {
keyword: one of 'oneOf' or 'anyOf' or 'allOf'
Validation:
1. Must be an array
2. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
2. Must have at least one subschema
3. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
*/
let subschemas = schema[keyword];
if (!Array.isArray(subschemas)) return {
isValid: false,
msg: "'" + keyword + "' property must be an array"
};
if (!subschemas.length) return {
isValid: false,
msg: "'" + keyword + "' must contain at least one subschema"
};

for (let i = 0; i < subschemas.length; i++) {
let subschema = subschemas[i];
Expand Down Expand Up @@ -3752,6 +3768,14 @@ function DataValidator(schema) {

let next_validator = this.getValidator(next_type);

if (!next_validator) {
if (next_schema.hasOwnProperty('oneOf')) {
next_validator = this.validateOneOf;
} else if (next_schema.hasOwnProperty('anyOf')) {
next_validator = this.validateAnyOf;
} else if (next_schema.hasOwnProperty('anyOf')) ;
}

if (next_validator) {
for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i]));
} else this.addError(coords, 'Unsupported type "' + next_type + '" for array items.');
Expand Down
40 changes: 32 additions & 8 deletions dist/react-json-form.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function getBlankArray(schema, getRef) {
let type = normalizeKeyword(schema.items.type);

if (!type) {
if (schema.items.hasOwnProperty['oneOf']) type = schema.items.oneOf[0];else if (schema.items.hasOwnProperty['anyOf']) type = schema.items.anyOf[0];else if (schema.items.hasOwnProperty['allOf']) type = schema.items.allOf[0];
if (Array.isArray(schema.items['oneOf'])) type = getSchemaType(schema.items.oneOf[0]);else if (Array.isArray(schema.items['anyOf'])) type = getSchemaType(schema.items.anyOf[0]);else if (Array.isArray(schema.items['allOf'])) type = getSchemaType(schema.items.allOf[0]);
}

if (type === 'array') {
Expand All @@ -245,6 +245,14 @@ function getBlankArray(schema, getRef) {
} else if (type === 'object') {
while (items.length < minItems) items.push(getBlankObject(schema.items, getRef));

return items;
} else if (type === 'oneOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
} else if (type === 'anyOf') {
while (items.length < minItems) items.push(getBlankOneOf(schema.items, getRef));

return items;
}

Expand Down Expand Up @@ -3282,23 +3290,26 @@ function validateArray(schema) {
} else {
if (!schema.items.hasOwnProperty('oneOf') && !schema.items.hasOwnProperty('anyOf') && !schema.items.hasOwnProperty('allOf')) return {
isValid: false,
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf' or 'allOf'"
msg: "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf'"
};
}

if (schema.hasOwnProperty('oneOf')) {
if (schema.items.hasOwnProperty('oneOf')) {
validation = validateOneOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('anyOf')) {
if (schema.items.hasOwnProperty('anyOf')) {
validation = validateAnyOf(schema.items);
if (!validation.isValid) return validation;
}

if (schema.hasOwnProperty('allOf')) {
validation = validateAllOf(schema.items);
if (!validation.isValid) return validation;
if (schema.items.hasOwnProperty('allOf')) {
// we don't support allOf inside array yet
return {
isValid: false,
msg: "Currently, 'allOf' inside array items is not supported"
};
}

return {
Expand Down Expand Up @@ -3360,13 +3371,18 @@ function validateSubschemas(schema, keyword) {
keyword: one of 'oneOf' or 'anyOf' or 'allOf'
Validation:
1. Must be an array
2. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
2. Must have at least one subschema
3. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
*/
let subschemas = schema[keyword];
if (!Array.isArray(subschemas)) return {
isValid: false,
msg: "'" + keyword + "' property must be an array"
};
if (!subschemas.length) return {
isValid: false,
msg: "'" + keyword + "' must contain at least one subschema"
};

for (let i = 0; i < subschemas.length; i++) {
let subschema = subschemas[i];
Expand Down Expand Up @@ -3752,6 +3768,14 @@ function DataValidator(schema) {

let next_validator = this.getValidator(next_type);

if (!next_validator) {
if (next_schema.hasOwnProperty('oneOf')) {
next_validator = this.validateOneOf;
} else if (next_schema.hasOwnProperty('anyOf')) {
next_validator = this.validateAnyOf;
} else if (next_schema.hasOwnProperty('anyOf')) ;
}

if (next_validator) {
for (let i = 0; i < data.length; i++) next_validator(next_schema, data[i], this.joinCoords([coords, i]));
} else this.addError(coords, 'Unsupported type "' + next_type + '" for array items.');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bhch/react-json-form",
"version": "2.7.0",
"version": "2.7.1",
"description": "Create forms using JSON Schema",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 964564b

Please sign in to comment.