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:
Almeida
2025-07-03 01:02:45 +01:00
committed by GitHub
parent 4dbeed933b
commit a5bd4cfe73
20 changed files with 183 additions and 199 deletions

View File

@@ -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', () => {