@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.
@@ -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: {