Skip to content

Commit cf98b6f

Browse files
committed
Fix #99: Validation for oneOf/anyOf failed within object
1 parent 93316b8 commit cf98b6f

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/dataValidation.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default function DataValidator(schema) {
9797
let next_schema = schema.items;
9898
if (next_schema.hasOwnProperty('$ref'))
9999
next_schema = this.getRef(next_schema.$ref);
100-
let next_type = normalizeKeyword(next_schema.type);
100+
let next_type = getSchemaType(next_schema);
101101

102102
let minItems = getKeyword(schema, 'minItems', 'min_items');
103103
let maxItems = getKeyword(schema, 'maxItems', 'max_items');
@@ -128,16 +128,9 @@ export default function DataValidator(schema) {
128128

129129
let next_validator = this.getValidator(next_type);
130130

131-
if (!next_validator) {
132-
if (next_schema.hasOwnProperty('oneOf')) {
133-
next_validator = this.validateOneOf;
134-
} else if (next_schema.hasOwnProperty('anyOf')) {
135-
next_validator = this.validateAnyOf;
136-
} else if (next_schema.hasOwnProperty('anyOf')) {
137-
// currently allOf is not supported in array items
138-
// next_validator = this.validateAllOf;
139-
}
140-
}
131+
// currently allOf is not supported in array items
132+
if (next_type === 'allOf')
133+
next_validator = null;
141134

142135
if (next_validator) {
143136
for (let i = 0; i < data.length; i++)
@@ -188,7 +181,7 @@ export default function DataValidator(schema) {
188181
next_schema['required'] = true;
189182
}
190183

191-
let next_type = normalizeKeyword(next_schema.type);
184+
let next_type = getSchemaType(next_schema);
192185

193186
let next_validator = this.getValidator(next_type);
194187

0 commit comments

Comments
 (0)