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

Enum with null throwing error #39

Closed
alexkwolfe opened this issue Aug 6, 2014 · 3 comments
Closed

Enum with null throwing error #39

alexkwolfe opened this issue Aug 6, 2014 · 3 comments

Comments

@alexkwolfe
Copy link

I'm trying to write a schema with an enum property that allows a null value.

My schema declares:

"definitions": {
  "foo": {
    "type": "object",
    "properties": {
      "bar": { "enum": [ "a", "b", "c", null ] },
    }
  }
}

And I am receiving this error:

jayschema/lib/schemaRegistry.js:142
    if (Object.prototype.hasOwnProperty.call(currentObj, 'id') &&
                                        ^
TypeError: Cannot convert null to object
  at hasOwnProperty (native)
  at Function.SchemaRegistry._getSubObjectsHavingIds (jayschema/lib/schemaRegistry.js:142:41)
  at [object Object].SchemaRegistry.register (jayschema/lib/schemaRegistry.js:216:35)
  at [object Object].JaySchema.register (jayschema/lib/jayschema.js:73:40)

Is this expected?

@natesilva
Copy link
Owner

null should be valid for an enum. I’m tracking this down.

@natesilva
Copy link
Owner

Fixed in 0.2.8. Thank you.

@alexkwolfe
Copy link
Author

Thanks so much for making a fix so quickly. And thanks for the library.

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

2 participants