Skip to content

Ref will not be converted if it is inside array passed to default #1002

@farwayer

Description

@farwayer

Context

  • node version: 6.7.0
  • joi version: 9.1

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

const schema = Joi.object().keys({
  authors: Joi.array().items(Joi.string()).default([Joi.ref('$user')]),
});

This also will not work:

Joi.array().items(Joi.string()).default(Joi.ref(['$user']))
Joi.array().items(Joi.string()).default(Joi.ref('[$user]'))
Joi.array().items(Joi.string()).default(Joi.ref('$user')).single()

Which result you had ?

{authors: [null]}

What did you expect ?

{authors: ['defaultUser']}

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