From e95b10849ca2e00807fcb2d1f0b7ac3b99c7d01a Mon Sep 17 00:00:00 2001 From: Giacomo Debidda Date: Thu, 25 Apr 2024 16:41:49 +0200 Subject: [PATCH] feat: render any z.union() as strings Zod unions can now be rendered as an array of string. The Zod union can contain multiple nested levels of Zod unions. The generated array of string is flattened and sorted. Added string representation for JS Symbol and BigInt in the `stringify` function. --- .ae/doc/zod-to-doc.api.json | 91 ++++++++++++++++++ .ae/zod-to-doc.api.md | 13 +++ api-docs/zod-to-doc.arrayfromzodunion.md | 19 ++++ api-docs/zod-to-doc.md | 2 + api-docs/zod-to-doc.stringsfromzodanytype.md | 13 +++ docs/assets/navigation.js | 2 +- docs/assets/search.js | 2 +- docs/functions/arrayFromZodSchema.html | 2 +- docs/functions/arrayFromZodUnion.html | 2 + .../functions/markdownTableFromZodSchema.html | 2 +- docs/functions/stringsFromZodAnyType.html | 2 + docs/index.html | 2 +- docs/modules.html | 4 +- fixtures/schemas.mjs | 37 +++++++- package-lock.json | 4 +- package.json | 2 +- src/lib.ts | 85 ++++++++++++++++- test/cli.mjs | 2 +- test/lib.mjs | 95 +++++++++++++++++++ 19 files changed, 367 insertions(+), 14 deletions(-) create mode 100644 api-docs/zod-to-doc.arrayfromzodunion.md create mode 100644 api-docs/zod-to-doc.stringsfromzodanytype.md create mode 100644 docs/functions/arrayFromZodUnion.html create mode 100644 docs/functions/stringsFromZodAnyType.html diff --git a/.ae/doc/zod-to-doc.api.json b/.ae/doc/zod-to-doc.api.json index c46ad7e..016a1db 100644 --- a/.ae/doc/zod-to-doc.api.json +++ b/.ae/doc/zod-to-doc.api.json @@ -213,6 +213,65 @@ "endIndex": 6 } }, + { + "kind": "Variable", + "canonicalReference": "@jackdbd/zod-to-doc!arrayFromZodUnion:var", + "docComment": "/**\n * Converts a Zod union into an array of strings.\n *\n * @public @experimental\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "arrayFromZodUnion: " + }, + { + "kind": "Content", + "text": ">(schema: S) => {\n error: " + }, + { + "kind": "Reference", + "text": "Error", + "canonicalReference": "!Error:interface" + }, + { + "kind": "Content", + "text": ";\n value?: undefined;\n} | {\n value: string[];\n error?: undefined;\n}" + } + ], + "fileUrlPath": "src/lib.ts", + "isReadonly": true, + "releaseTag": "Public", + "name": "arrayFromZodUnion", + "variableTypeTokenRange": { + "startIndex": 1, + "endIndex": 10 + } + }, { "kind": "Variable", "canonicalReference": "@jackdbd/zod-to-doc!markdownTableFromZodSchema:var", @@ -253,6 +312,38 @@ "startIndex": 1, "endIndex": 6 } + }, + { + "kind": "Variable", + "canonicalReference": "@jackdbd/zod-to-doc!stringsFromZodAnyType:var", + "docComment": "/**\n * Converts any Zod type into an array of strings.\n *\n * @public @experimental\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "stringsFromZodAnyType: " + }, + { + "kind": "Content", + "text": "(x: " + }, + { + "kind": "Reference", + "text": "ZodTypeAny", + "canonicalReference": "zod!ZodTypeAny:type" + }, + { + "kind": "Content", + "text": ") => string[]" + } + ], + "fileUrlPath": "src/lib.ts", + "isReadonly": true, + "releaseTag": "Public", + "name": "stringsFromZodAnyType", + "variableTypeTokenRange": { + "startIndex": 1, + "endIndex": 4 + } } ] } diff --git a/.ae/zod-to-doc.api.md b/.ae/zod-to-doc.api.md index 9001c62..c7061a1 100644 --- a/.ae/zod-to-doc.api.md +++ b/.ae/zod-to-doc.api.md @@ -5,6 +5,7 @@ ```ts import { z } from 'zod'; +import type { ZodTypeAny } from 'zod'; // @public export const arrayFromZodSchema: (schema: S) => { @@ -19,6 +20,15 @@ export const arrayFromZodSchema: (schema: S) => { error?: undefined; }; +// @public +export const arrayFromZodUnion: >(schema: S) => { + error: Error; + value?: undefined; +} | { + value: string[]; + error?: undefined; +}; + // Warning: (ae-internal-missing-underscore) The name "defaultZodValue" should be prefixed with an underscore because the declaration is marked as @internal // // @internal (undocumented) @@ -38,6 +48,9 @@ export const markdownTableFromZodSchema: (schema: S) = // @internal (undocumented) export const stringify: (x: any) => string; +// @public +export const stringsFromZodAnyType: (x: ZodTypeAny) => string[]; + // (No @packageDocumentation comment for this package) ``` diff --git a/api-docs/zod-to-doc.arrayfromzodunion.md b/api-docs/zod-to-doc.arrayfromzodunion.md new file mode 100644 index 0000000..92a1c48 --- /dev/null +++ b/api-docs/zod-to-doc.arrayfromzodunion.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@jackdbd/zod-to-doc](./zod-to-doc.md) > [arrayFromZodUnion](./zod-to-doc.arrayfromzodunion.md) + +## arrayFromZodUnion variable + +Converts a Zod union into an array of strings. + +**Signature:** + +```typescript +arrayFromZodUnion: >(schema: S) => { + error: Error; + value?: undefined; +} | { + value: string[]; + error?: undefined; +} +``` diff --git a/api-docs/zod-to-doc.md b/api-docs/zod-to-doc.md index b8e750e..f94710b 100644 --- a/api-docs/zod-to-doc.md +++ b/api-docs/zod-to-doc.md @@ -9,5 +9,7 @@ | Variable | Description | | --- | --- | | [arrayFromZodSchema](./zod-to-doc.arrayfromzodschema.md) | Converts a Zod schema into an array of objects. | +| [arrayFromZodUnion](./zod-to-doc.arrayfromzodunion.md) | Converts a Zod union into an array of strings. | | [markdownTableFromZodSchema](./zod-to-doc.markdowntablefromzodschema.md) | Creates a markdown table from a Zod schema. | +| [stringsFromZodAnyType](./zod-to-doc.stringsfromzodanytype.md) | Converts any Zod type into an array of strings. | diff --git a/api-docs/zod-to-doc.stringsfromzodanytype.md b/api-docs/zod-to-doc.stringsfromzodanytype.md new file mode 100644 index 0000000..bce963b --- /dev/null +++ b/api-docs/zod-to-doc.stringsfromzodanytype.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@jackdbd/zod-to-doc](./zod-to-doc.md) > [stringsFromZodAnyType](./zod-to-doc.stringsfromzodanytype.md) + +## stringsFromZodAnyType variable + +Converts any Zod type into an array of strings. + +**Signature:** + +```typescript +stringsFromZodAnyType: (x: ZodTypeAny) => string[] +``` diff --git a/docs/assets/navigation.js b/docs/assets/navigation.js index 8f865dc..b766504 100644 --- a/docs/assets/navigation.js +++ b/docs/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4uuVipJrShRslJKLCpKrHQrys+Nyk8JTs5IzU1U0lEqSCzJAMqlleYll2Tm5xXrY6rSyyjJzQEqzc7MS1GyMjOp1YEbmZtYlJ2SX54XkpiUk0rQaNyqMayIBQCQl5L8twAAAA==" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4uuVipJrShRslJKLCpKrHQrys+Nyk8JTs5IzU1U0lEqSCzJAMqlleYll2Tm5xXrY6rSyyjJzQEqzc7MS1GyMjOp1cFqZGgeUD8hE8GK8BiYm1iUnZJfnheSmJSTStCtuFXjsaK4pCgzL70YqtwxrzKksiAVm+lYFWIYHAsAEsDy92EBAAA=" \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js index 799d220..1da21dc 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4WQTWrDMBCF7zJr4VhNCcQHKHTd0EWNKKo1Jib6CZLStBW6e8eyTRZ16EYwM5/eezMJvLsGaNoEp8EqaHaPDKw0CA1I7+X3k3fmzamX7ohGAoOL1zTqL7aLg7Nh8xeqjtFoIjstQ0DSBshsRd5If1Luag/yQ+N/NvfhNTvBgNzwC5oEn+gDSVD/odpWeyL7AbUad56S0FdnDNoIYp69YhedH4kJ2dTA2prtqv2WC8Ha5UPpl0ahOFV8heKFKpkoTET1PGUj9XK9ntb5cSrMuyd4n8PXy60S1PTkfIs6VqPHcpc43uWuEL8J8TUhynYezqgHS0wrcv4FDBoAqBcCAAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA52TTU+EMBCG/8ucGxbKxkRuXkw8u3qQEFOhuGRpS9riioT/7lAguLFkjReSaZ953/mgPWh1NpCkPZwqWUBysycgmeCQgLG6ku/mXivxooo72R26hgOBVtd4W7Yyt5WSZuflgqMVNcJ5zYzh6AAwEI8J05p1c+qTRD2PwS/mP+KP+ZELdkV9gv4qL5g+FeosD+yt5tdstmGfXUYA3fgnJD18cG3GwSRAgzi4RbKseF2MW5sqwVQlBJcWsvnumedW6ZGYkF0IJA1JRINwn2UkXRLcuTtwVIRR5KGiC4piRD0UvaBijGIPFTvK9YeNWV48TH1ipW4TJY7mSxVmnmMPr/Mg6DL3Hih+hmFte4xGj58C7fQzrfnRmh9t5C87suOONguJV6F4Q2h+ErMEk511T2fVCFeN0KeB82mqhteVRCbNhuEbzCK3c6kDAAA="; \ No newline at end of file diff --git a/docs/functions/arrayFromZodSchema.html b/docs/functions/arrayFromZodSchema.html index 29247f7..ea9fba7 100644 --- a/docs/functions/arrayFromZodSchema.html +++ b/docs/functions/arrayFromZodSchema.html @@ -1,2 +1,2 @@ arrayFromZodSchema | @jackdbd/zod-to-doc

Function arrayFromZodSchema

  • Experimental

    Converts a Zod schema into an array of objects.

    -

    Type Parameters

    • S extends AnyZodObject

    Parameters

    • schema: S

    Returns {
        error: Error;
        value?: undefined;
    } | {
        error?: undefined;
        value: {
            default: any;
            description: string;
            key: string;
        }[];
    }

Generated using TypeDoc

\ No newline at end of file +

Type Parameters

  • S extends AnyZodObject

Parameters

  • schema: S

Returns {
    error: Error;
    value?: undefined;
} | {
    error?: undefined;
    value: {
        default: any;
        description: string;
        key: string;
    }[];
}

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/arrayFromZodUnion.html b/docs/functions/arrayFromZodUnion.html new file mode 100644 index 0000000..de3045a --- /dev/null +++ b/docs/functions/arrayFromZodUnion.html @@ -0,0 +1,2 @@ +arrayFromZodUnion | @jackdbd/zod-to-doc

Function arrayFromZodUnion

  • Experimental

    Converts a Zod union into an array of strings.

    +

    Type Parameters

    • S extends ZodUnion<readonly [ZodTypeAny, ZodTypeAny]>

    Parameters

    • schema: S

    Returns {
        error: Error;
        value?: undefined;
    } | {
        error?: undefined;
        value: string[];
    }

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/markdownTableFromZodSchema.html b/docs/functions/markdownTableFromZodSchema.html index c11c57c..b5c7637 100644 --- a/docs/functions/markdownTableFromZodSchema.html +++ b/docs/functions/markdownTableFromZodSchema.html @@ -1,4 +1,4 @@ markdownTableFromZodSchema | @jackdbd/zod-to-doc

Function markdownTableFromZodSchema

  • Experimental

    Creates a markdown table from a Zod schema.

    Type Parameters

    • S extends AnyZodObject

    Parameters

    • schema: S

      The Zod schema to convert.

    Returns {
        error: Error;
        value?: undefined;
    } | {
        error?: undefined;
        value: string;
    }

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/functions/stringsFromZodAnyType.html b/docs/functions/stringsFromZodAnyType.html new file mode 100644 index 0000000..f0498d5 --- /dev/null +++ b/docs/functions/stringsFromZodAnyType.html @@ -0,0 +1,2 @@ +stringsFromZodAnyType | @jackdbd/zod-to-doc

Function stringsFromZodAnyType

  • Experimental

    Converts any Zod type into an array of strings.

    +

    Parameters

    • x: ZodTypeAny

    Returns string[]

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 1be4f63..16ff9a1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -125,4 +125,4 @@

License

© 2024 Giacomo Debidda // MIT License

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index c058367..9c1ac42 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,4 +1,6 @@ @jackdbd/zod-to-doc

@jackdbd/zod-to-doc

Inject your Zod schemas into your docs.

Index

Functions

Generated using TypeDoc

\ No newline at end of file +stringsFromZodAnyType +

Generated using TypeDoc

\ No newline at end of file diff --git a/fixtures/schemas.mjs b/fixtures/schemas.mjs index 34c0f83..75542d6 100644 --- a/fixtures/schemas.mjs +++ b/fixtures/schemas.mjs @@ -1,10 +1,43 @@ import { z } from 'zod' +export const color = z.union([ + z.literal('red'), + z.literal('green').describe('The green color'), + z.literal('blue') +]) + +// https://zod.dev/?id=literals +export const assorted_literals = z.union([ + z.literal(), + z.literal().describe('An empty literal'), + z.literal(123).describe('The literal number `123`'), + z.literal(456), + z.literal(BigInt(9007199254740991)).describe('A very big number'), + z.literal('tuna').describe('The string `tuna`'), + z.literal(true).describe('The boolean `true`'), + z.literal(Symbol('terrific')).describe('The symbol `terrific`') +]) + +// https://zod.dev/?id=unions +export const assorted_union = z.union([ + z.literal('tuna').describe('The literal string `tuna`'), + z.boolean(), + z.literal(123).describe('The literal number `123`'), + z.literal(456), + z.number().min(5).max(9), + z.number().min(1).max(10).describe('A number between 1 and 10'), + z.bigint(), + z.string().min(3).max(5).describe('A string with 3 to 5 characters'), + z + .object({ foo: z.string(), color: color }) + .describe('An object with a given description'), + z.object({ bar: z.string(), baz: z.number() }) +]) + export const car_manufacturer = z .literal('Ferrari') .or(z.literal('Ford')) - .or(z.literal('Ford')) - .or(z.literal('Honda')) + .or(z.literal('Honda').describe('The Honda car manufacturer')) .or(z.literal('Peugeot')) .or(z.literal('Toyota')) .or(z.literal('Volkswagen')) diff --git a/package-lock.json b/package-lock.json index 6b7bdbf..1fd3ddf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@jackdbd/zod-to-doc", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@jackdbd/zod-to-doc", - "version": "1.0.6", + "version": "1.0.7", "license": "MIT", "dependencies": { "ansi-colors": "^4.1.3", diff --git a/package.json b/package.json index 47110d9..8b715b3 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "build:ts:watch": "tsc -p tsconfig.json --watch", "clean": "rimraf coverage/lcov.info dist/ tsconfig.tsbuildinfo", "commitlint": "commitlint --config ./config/commitlint.cjs --to HEAD --verbose", - "dev": "run-p 'build:ts:watch' 'test:watch'", + "dev": "DEBUG='' run-p 'build:ts:watch' 'test:watch'", "preexample": "chmod u+x ./dist/cli.js", "example": "run-s 'example:car'", "example:car": "./dist/cli.js --module ./fixtures/schemas.mjs --schema car --placeholder car-table --title '#### Car table' --filepath tpl.readme.md", diff --git a/src/lib.ts b/src/lib.ts index 4b689aa..297c4bc 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -5,6 +5,7 @@ */ import defDebug from 'debug' import { z } from 'zod' +import type { ZodTypeAny, ZodUnionOptions } from 'zod' import { DEBUG_PREFIX } from './constants.js' const debug = defDebug(`${DEBUG_PREFIX}:lib`) @@ -22,6 +23,73 @@ export const defaultZodValue = (value: any) => { } } +/** + * Converts any Zod type into an array of strings. + * + * @public + * @experimental + */ +export const stringsFromZodAnyType = (x: ZodTypeAny) => { + if (x instanceof z.ZodBigInt) { + return x.description ? [x.description] : ['A BigInt'] + } else if (x instanceof z.ZodBoolean) { + return x.description ? [x.description] : ['A Boolean'] + } else if (x instanceof z.ZodLiteral) { + if (x.value) { + if (x.description) { + return [`${stringify(x.value)} (${x.description})`] + } else { + return [stringify(x.value)] + } + } else { + if (x.description) { + return [`A literal (${x.description})`] + } else { + return [`A literal`] + } + } + } else if (x instanceof z.ZodNumber) { + // TODO: get min,max from these checks? + // console.log('=== x._def.checks ===', x._def.checks) + return x.description ? [x.description] : ['A Number'] + } else if (x instanceof z.ZodObject) { + // const res = arrayFromZodSchema(x as any) + return x.description ? [x.description] : ['An objects'] + } else if (x instanceof z.ZodString) { + return x.description ? [x.description] : ['A String'] + } else if (x instanceof z.ZodUnion) { + const arr: string[] = x.options.map((opt: z.ZodAny) => { + return stringsFromZodAnyType(opt) + }) + const strings = arr.flat() + strings.sort() + return strings + } else { + // console.log('=== stringFromZodAnyType x._def ===', x._def) + return x.description ? [x.description] : ['TODO'] + } +} + +/** + * Converts a Zod union into an array of strings. + * + * @public + * @experimental + */ +export const arrayFromZodUnion = >( + schema: S +) => { + if (!schema.options) { + return { error: new Error(`schema.options is not defined.`) } + } + + debug(`Zod schema.options => JS array`) + const arr = schema.options.map(stringsFromZodAnyType).flat() + arr.sort() + + return { value: arr } +} + /** * Converts a Zod schema into an array of objects. * @@ -32,8 +100,7 @@ export const arrayFromZodSchema = (schema: S) => { if (!schema.shape) { return { error: new Error(`schema.shape is not defined.`) } } - - debug(`Zod schema => JS array`) + debug(`Zod schema.shape => JS array`) const arr = Object.entries(schema.shape).map(([key, value]) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const val = value as any @@ -92,6 +159,20 @@ export const stringify = (x: any) => { return `\`${x}\`` } + if (typeof x === 'bigint') { + // The trailing "n" is not part of the string. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString + // https://github.com/GoogleChromeLabs/jsbi/issues/30#issuecomment-521449285 + return x.toString() + } + + if (typeof x === 'symbol') { + // Because Symbol has a [@@toPrimitive]() method, that method always takes + // priority over toString() when a Symbol object is coerced to a string. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString + return x.toString() + } + if (x.length === 0) { return `\`[]\`` } else { diff --git a/test/cli.mjs b/test/cli.mjs index 4981b77..6875284 100644 --- a/test/cli.mjs +++ b/test/cli.mjs @@ -77,7 +77,7 @@ describe('cli', () => { const { stderr, stdout } = exception assert.equal(stdout, '') - assert.match(stderr, /Module containing Zod schemas not found/) + assert.match(stderr, /module not found/) } } ) diff --git a/test/lib.mjs b/test/lib.mjs index ed27a9f..148c2fa 100644 --- a/test/lib.mjs +++ b/test/lib.mjs @@ -3,14 +3,20 @@ import { describe, it } from 'node:test' import { z } from 'zod' import { arrayFromZodSchema, + arrayFromZodUnion, markdownTableFromZodSchema, + stringsFromZodAnyType, stringify } from '../dist/lib.js' import { + assorted_literals, + assorted_union, car, car_manufacturer, car_model, car_tire, + car_tire_manufacturer, + color, dealership, employee, year @@ -124,6 +130,95 @@ describe('stringify', () => { }) }) +describe('stringsFromZodAnyType', () => { + it('returns a sorted list of strings when passed a z.union() of string literals', () => { + const union = z.union([ + z.literal('red'), + z.literal('green').describe('The green color'), + z.literal('blue') + ]) + + const arr = stringsFromZodAnyType(union) + + assert.equal(arr[0], '`"blue"`') + assert.equal(arr[1], '`"green"` (The green color)') + assert.equal(arr[2], '`"red"`') + }) + + it('renders a sorted list of strings even when there are multiple levels of nested z.union()', () => { + const american_cars = z.union([z.literal('Dodge'), z.literal('Ford')]) + const german_cars = z.union([z.literal('BMW'), z.literal('Volkswagen')]) + const japanese_cars = z.union([ + z.literal('Honda').describe('The Honda car manufacturer'), + z.literal('Subaru') + ]) + + const union = z.union([ + z.literal('Aston Martin'), + z.literal('Ferrari'), + american_cars, + german_cars, + japanese_cars, + z.literal('Peugeut') + ]) + + const arr = stringsFromZodAnyType(union) + + assert.equal(arr[0], '`"Aston Martin"`') + assert.equal(arr[1], '`"BMW"`') + assert.equal(arr[2], '`"Dodge"`') + assert.equal(arr[3], '`"Ferrari"`') + assert.equal(arr[4], '`"Ford"`') + assert.equal(arr[5], '`"Honda"` (The Honda car manufacturer)') + assert.equal(arr[6], '`"Peugeut"`') + assert.equal(arr[7], '`"Subaru"`') + assert.equal(arr[8], '`"Volkswagen"`') + }) +}) + +describe('arrayFromZodUnion', () => { + it('returns a sorted list of strings when passed a z.union() of string literals', () => { + const union = z.union([ + z.literal('red'), + z.literal('green').describe('The green color'), + z.literal('blue') + ]) + + const { error, value } = arrayFromZodUnion(union) + + assert.equal(error, undefined) + assert.equal(value[0], '`"blue"`') + assert.equal(value[1], '`"green"` (The green color)') + assert.equal(value[2], '`"red"`') + }) + + it('returns a sorted list of strings even when there are multiple levels of nested z.union()', () => { + const american_cars = z.union([z.literal('Dodge'), z.literal('Ford')]) + + const french_cars = z.union([z.literal('Peugeut'), z.literal('Renault')]) + const german_cars = z.union([z.literal('BMW'), z.literal('Volkswagen')]) + const european_cars = z.union([ + z.literal('Ferrari'), + french_cars, + german_cars + ]) + + const union = z.union([american_cars, european_cars, z.literal('Subaru')]) + + const { error, value } = arrayFromZodUnion(union) + + assert.equal(error, undefined) + assert.equal(value[0], '`"BMW"`') + assert.equal(value[1], '`"Dodge"`') + assert.equal(value[2], '`"Ferrari"`') + assert.equal(value[3], '`"Ford"`') + assert.equal(value[4], '`"Peugeut"`') + assert.equal(value[5], '`"Renault"`') + assert.equal(value[6], '`"Subaru"`') + assert.equal(value[7], '`"Volkswagen"`') + }) +}) + describe('arrayFromZodSchema', () => { it('returns an error when the schema is a z.number()', () => { const res = arrayFromZodSchema(year)