Skip to content

Commit

Permalink
feat: pass options.names as a second argument to a Vest suite
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam committed Jun 25, 2023
1 parent 420e862 commit 593866e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions vest/src/__tests__/vest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ describe('vestResolver', () => {
),
).toMatchSnapshot();
});

it('should call a suite with validated field names as the second argument', async () => {
const suite = vi.fn(validationSuite) as any as typeof validationSuite;

await vestResolver(suite)(validData, undefined, {
fields: { username: fields.username },
names: ['username'],
shouldUseNativeValidation,
});

expect(suite).toHaveBeenCalledTimes(1);
expect(suite).toHaveBeenCalledWith(validData, ['username']);
});
});
4 changes: 2 additions & 2 deletions vest/src/vest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const vestResolver: Resolver =
async (values, _context, options) => {
const result =
resolverOptions.mode === 'sync'
? schema(values)
: await promisify(schema)(values);
? schema(values, options.names)
: await promisify(schema)(values, options.names);

if (result.hasErrors()) {
return {
Expand Down

0 comments on commit 593866e

Please sign in to comment.