Skip to content

Commit 06bf5c0

Browse files
committed
Merge pull request #15 from NicolasPelletier/master
Remove the restriction on top-level schema type.
2 parents 0c9ad81 + a494cf6 commit 06bf5c0

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

lib/valid-schema.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function validateSchema(schema, names) {
263263
validateArray(schema, names);
264264
validateItem(schema, names);
265265
// defaults are applied last after schema is validated
266-
validateDefault(schema, names)
266+
validateDefault(schema, names);
267267
}
268268

269269
module.exports = function(schema) {
@@ -279,9 +279,6 @@ module.exports = function(schema) {
279279
throw new Error('Schema: \'type\' is required');
280280
}
281281
assertType(schema, 'type', 'string', []);
282-
if (schema.type !== 'object' && schema.type !== 'array') {
283-
throw new Error('Schema: \'type\' is \'' + schema.type + '\' when it should be either \'object\' or \'array\'');
284-
}
285282

286283
validateSchema(schema, []);
287284
};

test/schema-basic-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ vows.describe('Schema Basic').addBatch({
3232
'when schema is not an object': schemaShouldBeInvalid(schemaNotAnObject, { errMsg: 'Schema is a string when it should be an object' }),
3333
'when type attribue is missing': schemaShouldBeInvalid(schemaWithoutType, { errMsg: 'Schema: \'type\' is required' }),
3434
'when type attribute is not a string': schemaShouldBeInvalid(schemaInvalidType, { errMsg: 'Schema: \'type\' attribute is an integer when it should be a string' }),
35-
'when type attribute is neither \'object\' nor \'array\'': schemaShouldBeInvalid(schemaInappropriateType, { errMsg: 'Schema: \'type\' is \'string\' when it should be either \'object\' or \'array\'' }),
3635
'when type attribute is \'object\'': schemaShouldBeValid(schemaEmptyObject),
3736
'when type attribute is \'array\'': schemaShouldBeValid(schemaEmptyArray)
3837
}).export(module);

0 commit comments

Comments
 (0)