Skip to content

Label declaration/Validation #803

@adrien-candiotti

Description

@adrien-candiotti

Label declaration on Joi objects shadows the name of attributes that fails to be validated in the error message.

Example:

Joi.object({color: Joi.string().regex(/#[0-9a-fA-F]{6}/)}).label("test");

If I post a payload with a color field wrongly formatted I get:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "child \"test\" fails because [\"test\" with value \"string\" fails to match the required pattern: /^[0-9A-Fa-f]{6}$/]",
  "validation": {
    "source": "payload",
    "keys": [
      "color"
    ]
  }
}

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