mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat!: use zod v4 (#10922)
* feat: zod 4 * feat: zod v3, but v4 feat: validation error class Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * chore: bump --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
import { enableValidators, disableValidators, isValidationEnabled, normalizeArray } from '../src/index.js';
|
||||
import { z } from 'zod/v4';
|
||||
import {
|
||||
enableValidators,
|
||||
disableValidators,
|
||||
isValidationEnabled,
|
||||
normalizeArray,
|
||||
ValidationError,
|
||||
} from '../src/index.js';
|
||||
import { validate } from '../src/util/validation.js';
|
||||
|
||||
describe('validation', () => {
|
||||
test('enables validation', () => {
|
||||
@@ -11,6 +19,17 @@ describe('validation', () => {
|
||||
disableValidators();
|
||||
expect(isValidationEnabled()).toBeFalsy();
|
||||
});
|
||||
|
||||
test('validation error', () => {
|
||||
try {
|
||||
validate(z.never(), 1, true);
|
||||
throw new Error('validation should have failed');
|
||||
} catch (error) {
|
||||
expect(error).toBeInstanceOf(ValidationError);
|
||||
expect((error as ValidationError).message).toBe('✖ Invalid input: expected never, received number');
|
||||
expect((error as ValidationError).cause).toBeInstanceOf(z.ZodError);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeArray', () => {
|
||||
|
||||
Reference in New Issue
Block a user