Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required validator throws on null values #74

Closed
kgkma opened this issue Mar 6, 2019 · 0 comments
Closed

Required validator throws on null values #74

kgkma opened this issue Mar 6, 2019 · 0 comments

Comments

@kgkma
Copy link
Contributor

kgkma commented Mar 6, 2019

Description
When a definition of type object specifies required properties, passing in null to the validate method throws a TypeError: Cannot read property 'hasOwnProperty' of null.

Steps to reproduce

const schema = {
  def: {
    type: 'object',
    properties: {
      foo: { type: 'string' }
    },
    required: ['foo'],
  },
};
const env = djv();
env.addSchema('test', schema);

const obj = null;
const errors = env.validate('test#/def', obj); // should return the errors object

Expected behaviour
The validation fails and errors is populated with the validation error.

Actual behaviour
TypeError: Cannot read property 'hasOwnProperty' of null is thrown.

Version
2.1.1

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

No branches or pull requests

1 participant