Skip to content

Commit 4364395

Browse files
committed
Optional properties support
1 parent ec9858e commit 4364395

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function build (schema, options) {
1111
// used to support patternProperties and additionalProperties
1212
// they need to check if a field belongs to the properties in the schema
1313
code += `
14-
const properties = ${JSON.stringify(schema.properties)}
14+
const properties = ${JSON.stringify(schema.properties)} || {}
1515
`
1616
code += `
1717
${$asString.toString()}
@@ -264,7 +264,7 @@ function buildObject (schema, code, name, externalSchema, fullSchema) {
264264

265265
var laterCode = ''
266266

267-
Object.keys(schema.properties).forEach((key, i, a) => {
267+
Object.keys(schema.properties || {}).forEach((key, i, a) => {
268268
// Using obj.key !== undefined instead of obj.hasOwnProperty(prop) for perf reasons,
269269
// see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion.
270270
code += `

0 commit comments

Comments
 (0)