Skip to content

describe doesn't work for empty() breaking lout #1249

@karpikpl

Description

@karpikpl

Context

  • node version: 8.1.4
  • joi version: 10.6.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): hapi
  • any other relevant information:

What are you trying to achieve or the steps to reproduce ?

Describe your issue here, include schemas and inputs you are validating if needed.

I've narrowed it down to this:

'use strict';
const Joi = require('joi');

const schema = Joi.object({
    name: Joi.empty()
});

console.log(schema.describe());

Which result you had ?

 description.flags[flag] = this._flags[flag].describe();
                                                                   ^

TypeError: Cannot read property 'describe' of undefined
    at internals.String.describe (/Users//projects/mljmocks/ods-api/joi-test/node_modules/joi/lib/types/any/index.js:682:68)
    at internals.Alternatives.describe (/Users//projects/mljmocks/ods-api/joi-test/node_modules/joi/lib/types/alternatives/index.js:143:47)
    at internals.Object.describe (/Users//projects/mljmocks/ods-api/joi-test/node_modules/joi/lib/types/object/index.js:613:64)
    at Object.<anonymous> (/Users//projects/mljmocks/ods-api/joi-test/joi-test.js:9:20)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)

What did you expect ?

schema description.

I also wanted to use lout but it causes same exception when accessing /docs:

Debug: internal, implementation, error
    TypeError: Uncaught error: Cannot read property 'describe' of undefined

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions