Skip to content

Passing meta data from schema to validation result #2939

Open
@minhnq013

Description

@minhnq013

Support plan

  • is this issue currently blocking your project? yes:
  • is this issue affecting a production system? no:

Context

  • node version: v16.14.0
  • module version: 17.6.0
  • environment browser
  • used with (e.g. hapi application, another framework, standalone, ...):
  • any other relevant information:

How can we help?

Hi team,
I would like to tag a schema with some metadata that will be included in any validation result of that schema or its children schema.
Is this possible with the current state of Joi?

I think it is similar to artifact but also work for failed rule.

      const schema = Joi.object({
        name: Joi.string().required(),
      })
        .schemaTag('special-tag')

      const result = schema.validate(
        { gaga: 'gaga' }
      )

      console.log(result.details.map(detail => detail.schemaTag))) // ['special-tag']

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions