Skip to content

Exception throw on undefined object key makes it difficult to track down issue #740

@kpdecker

Description

@kpdecker

Accidentally did something like the following:

      validate: {
        payload: {
          data: mySchema.data
        }
      },

Where mySchema.data is undefined. This threw the following:

[Error: Invalid schema content: ]
Error: Invalid schema content:
    at Object.exports.assert (mycode/node_modules/hapi/node_modules/hoek/lib/index.js:731:11)
    at Object.exports.schema (mycode/node_modules/hapi/node_modules/joi/lib/cast.js:66:10)
    at internals.Object.keys (mycode/node_modules/hapi/node_modules/joi/lib/object.js:282:25)
    at Object.exports.schema (mycode/node_modules/hapi/node_modules/joi/lib/cast.js:47:33)
    at root.compile (mycode/node_modules/hapi/node_modules/joi/lib/index.js:113:21)
    at Object.internals.compileRule (mycode/node_modules/hapi/lib/route.js:256:88)
    at mycode/node_modules/hapi/lib/route.js:98:38
    at Array.forEach (native)
    at new module.exports.internals.Route (mycode/node_modules/hapi/lib/route.js:96:47)
    at internals.Connection._addRoute (mycode/node_modules/hapi/lib/connection.js:361:17)

Which does not provide much that's actionable. Ideally there would be some sort of reference to the data field and potentially the fact that this is the payload structure (although that would likely need to be in hapi vs. joi, hapi hapi joi joi).

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions