@forklaunch/validator 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/shared/types/schema.types.d.ts +9 -2
- package/lib/src/shared/types/schema.types.d.ts.map +1 -1
- package/lib/src/typebox/staticSchemaValidator.d.ts +25 -23
- package/lib/src/typebox/staticSchemaValidator.d.ts.map +1 -1
- package/lib/src/typebox/staticSchemaValidator.js +4 -0
- package/lib/src/typebox/typeboxSchemaValidator.d.ts +7 -1
- package/lib/src/typebox/typeboxSchemaValidator.d.ts.map +1 -1
- package/lib/src/typebox/typeboxSchemaValidator.js +12 -1
- package/lib/src/zod/staticSchemaValidator.d.ts +25 -23
- package/lib/src/zod/staticSchemaValidator.d.ts.map +1 -1
- package/lib/src/zod/staticSchemaValidator.js +4 -0
- package/lib/src/zod/zodSchemaValidator.d.ts +7 -1
- package/lib/src/zod/zodSchemaValidator.d.ts.map +1 -1
- package/lib/src/zod/zodSchemaValidator.js +10 -5
- package/lib/tests/typebox/schemaValidator.test.js +22 -1
- package/lib/tests/utils/compare.js +2 -2
- package/lib/tests/utils/mockSchemaValidator.d.ts +3 -1
- package/lib/tests/utils/mockSchemaValidator.d.ts.map +1 -1
- package/lib/tests/utils/mockSchemaValidator.js +6 -2
- package/lib/tests/zod/schemaValidator.test.js +16 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/lib/eslint.config.d.mts +0 -1134
- package/lib/eslint.config.d.mts.map +0 -1
- package/lib/eslint.config.mjs +0 -10
- package/lib/jest.config.d.ts +0 -4
- package/lib/jest.config.d.ts.map +0 -1
- package/lib/jest.config.js +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateSchema } from '@anatine/zod-openapi';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { array, number, openapi, optional, parse, schemify, string, union, validate } from '../../src/zod';
|
|
3
|
+
import { array, enum_, number, openapi, optional, parse, schemify, string, union, validate } from '../../src/zod';
|
|
4
4
|
import { compare } from '../utils/compare';
|
|
5
5
|
describe('zod schema validator tests', () => {
|
|
6
6
|
let schema;
|
|
@@ -118,6 +118,21 @@ describe('zod schema validator tests', () => {
|
|
|
118
118
|
hello: z.literal('world')
|
|
119
119
|
}));
|
|
120
120
|
});
|
|
121
|
+
test('enum', async () => {
|
|
122
|
+
let TestSingleEnum;
|
|
123
|
+
(function (TestSingleEnum) {
|
|
124
|
+
TestSingleEnum["WORLD"] = "world";
|
|
125
|
+
})(TestSingleEnum || (TestSingleEnum = {}));
|
|
126
|
+
const schemified = enum_(TestSingleEnum);
|
|
127
|
+
compare(schemified, z.union([z.literal('world')]));
|
|
128
|
+
let TestMultipleEnum;
|
|
129
|
+
(function (TestMultipleEnum) {
|
|
130
|
+
TestMultipleEnum["WORLD"] = "world";
|
|
131
|
+
TestMultipleEnum["HELLO"] = "hello";
|
|
132
|
+
})(TestMultipleEnum || (TestMultipleEnum = {}));
|
|
133
|
+
const schemifiedMultiple = enum_(TestMultipleEnum);
|
|
134
|
+
compare(schemifiedMultiple, z.union([z.literal('world'), z.literal('hello')]));
|
|
135
|
+
});
|
|
121
136
|
test('validate', async () => {
|
|
122
137
|
validate(schemified, {
|
|
123
138
|
hello: {
|