Skip to content

errors is always undefined in ValidationResult #2523

@benknab

Description

@benknab

Support plan

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

Context

  • node version: v14.13.0
  • module version with issue: v17.3.0
  • last module version without issue: ?
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

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

I was trying to use the errors property in the ValidationResult object but it is always undefined, after reading the related docs I saw that the validation errors are returned in the error property, but errors is included in the ValidationResult type, see: https://github.com/sideway/joi/blob/c451ef5575c40622ea6bd64810a79ea10e5cb020/lib/index.d.ts#L644-L649.

// `error` is `ValidationError` if validation errors are found
// `errors` is always `undefined`
const { error, errors } = uploadParamsSchema.validate(params)

What was the result you got?

errors is always undefined

What result did you expect?

errors behaves as error or errors is not included in the ValidationResult type

Metadata

Metadata

Assignees

Labels

bugBug or defecttypesTypeScript type definitions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions