Skip to content
Snippets Groups Projects
Commit 8f95bb39 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Handle not-schema values on pending tests; cleanup

parent bef38d08
No related branches found
No related tags found
No related merge requests found
const ALL_TYPES = ['array', 'object', 'integer', 'number', 'string', 'boolean', 'null']; const SCALAR_TYPES = ['integer', 'number', 'string', 'boolean', 'null'];
const ALL_TYPES = ['array', 'object'].concat(SCALAR_TYPES);
const MOST_NEAR_DATETIME = 2524608000000; const MOST_NEAR_DATETIME = 2524608000000;
...@@ -9,6 +10,7 @@ const MIN_NUMBER = -100; ...@@ -9,6 +10,7 @@ const MIN_NUMBER = -100;
const MAX_NUMBER = 100; const MAX_NUMBER = 100;
export default { export default {
SCALAR_TYPES,
ALL_TYPES, ALL_TYPES,
MIN_NUMBER, MIN_NUMBER,
MAX_NUMBER, MAX_NUMBER,
......
...@@ -37,6 +37,11 @@ function traverse(schema, path, resolve, rootSchema) { ...@@ -37,6 +37,11 @@ function traverse(schema, path, resolve, rootSchema) {
if (schema.not && typeof schema.not === 'object') { if (schema.not && typeof schema.not === 'object') {
schema = utils.notValue(schema.not, utils.omitProps(schema, ['not'])); schema = utils.notValue(schema.not, utils.omitProps(schema, ['not']));
// build new object value from not-schema!
if (schema.type && schema.type === 'object') {
return traverse(schema, path.concat(['not']), resolve, rootSchema);
}
} }
if ('const' in schema) { if ('const' in schema) {
......
...@@ -265,7 +265,7 @@ function notValue(schema, parent) { ...@@ -265,7 +265,7 @@ function notValue(schema, parent) {
} }
if (schema.type) { if (schema.type) {
copy.type = random.pick(env.ALL_TYPES.filter(x => { copy.type = random.pick(env.SCALAR_TYPES.filter(x => {
const types = Array.isArray(schema.type) ? schema.type : [schema.type]; const types = Array.isArray(schema.type) ? schema.type : [schema.type];
return types.every(type => { return types.every(type => {
......
...@@ -33,7 +33,7 @@ function objectType(value, path, resolve, traverseCallback) { ...@@ -33,7 +33,7 @@ function objectType(value, path, resolve, traverseCallback) {
&& utils.hasProperties(value, 'minProperties', 'maxProperties', 'dependencies', 'required') && utils.hasProperties(value, 'minProperties', 'maxProperties', 'dependencies', 'required')
) { ) {
// just nothing // just nothing
return {}; return null;
} }
if (optionAPI('requiredOnly') === true) { if (optionAPI('requiredOnly') === true) {
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
"notBoolean" "notBoolean"
] ]
}, },
"skip": true,
"valid": true "valid": true
}, },
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment