Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

Array schema ref with required props #12

Open
natlibfi-arlehiko opened this issue Apr 6, 2016 · 1 comment
Open

Array schema ref with required props #12

natlibfi-arlehiko opened this issue Apr 6, 2016 · 1 comment

Comments

@natlibfi-arlehiko
Copy link

The following schema does not work:

  1. A property references a schema which resolves to an array type
  2. The array items is a reference to a inner definition
  3. The definition resolves to an object which has mandatory properties

Instead of returning a formatted error JJVE throws an exception: TypeError: Cannot read property 'type' of undefined.

My workaround for this bug is to replace the references in the schema with the actual sub-schemas:

env.addSchema('foo', schema_foo);

errors = env.validate(schema, data);

if (errors) {
  schema.properties.foo = schema_foo;
  throw new Error(je(schema, data, errors);
}
@natlibfi-arlehiko
Copy link
Author

PR #13 provides a test for this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant