express-validator icon indicating copy to clipboard operation
express-validator copied to clipboard

Property 'errors' is private and only accessible within class 'Result<T>'.

Open ctooley21 opened this issue 1 year ago • 2 comments

Describe the bug

The errors property for ResultWithContext is marked as private on package version 7.0.1 and TypeScript version 5.1.6

To Reproduce

Follow the TypeScript example on the docs site

Expected behavior

The property is accessible

Current behavior

A typescript error is generated, and typescript building fails with the error: error TS2341: Property 'errors' is private and only accessible within class 'Result<T>'.

Environment:

  • Express-validator version: 7.0.1
  • Express version: 5.0.0-beta.1
  • Node.js version: 18.16.1

ctooley21 avatar Aug 24 '23 00:08 ctooley21

The property is accessible

Nope, that's not desired behaviour - the docs are incorrect, they should be fixed

gustavohenke avatar Aug 24 '23 01:08 gustavohenke

The property is accessible

Nope, that's not desired behaviour - the docs are incorrect, they should be fixed

Understood. Can you provide any guidance on how to exit a custom validation run if one of the validation chains fails?

ctooley21 avatar Aug 24 '23 13:08 ctooley21

have you found a way to resolve this?

wmtrinu avatar Mar 03 '24 21:03 wmtrinu

Use Result#array().

gustavohenke avatar Mar 03 '24 22:03 gustavohenke

The way I wrote this docs page was a bit nonsense too, so I fixed that up. Sorry team! 🫡

gustavohenke avatar May 18 '24 04:05 gustavohenke