deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

validate only returns first error

Open rjurado01 opened this issue 2 years ago • 2 comments

When I check documentation I see that validate should returns an array of errors for diferent properties:

image

But when I validate object with some errors, I only get first:

import { validate } from '@deepkit/type';

interface Article {
    id: number;
    title: string;
}

validate<Article>({}));

returns:

[
  ValidationErrorItem {
    path: 'id',
    code: 'type',
    message: 'Not a number'
  }
]

I expect:

[
  ValidationErrorItem {
    path: 'id',
    code: 'type',
    message: 'Not a number'
  },
  ValidationErrorItem {
    path: 'title',
    code: 'type',
    message: 'Not a string'
  }
]

I'm using: "@deepkit/type": "^1.0.1-alpha.71"

rjurado01 avatar Jul 04 '22 18:07 rjurado01

What about validates?

marcus-sa avatar Jul 05 '22 07:07 marcus-sa

What about validates?

According to the documentation the correct method to get an array of errors is validate:

Screenshot_20220708_083726

validates returns a boolean.

rjurado01 avatar Jul 08 '22 06:07 rjurado01

Thanks for the report, fixed in https://github.com/deepkit/deepkit-framework/commit/7e965bd9bafe437e6a5340c1c3b22360b50d1ed7

marcj avatar Dec 03 '22 14:12 marcj