Skip to content

feat: zod plugin improvments#160

Merged
kumalg merged 5 commits into
feature/zod-pluginfrom
feature/zod-plugin-enum-and-json-schema
Jan 9, 2026
Merged

feat: zod plugin improvments#160
kumalg merged 5 commits into
feature/zod-pluginfrom
feature/zod-plugin-enum-and-json-schema

Conversation

@kumalg

@kumalg kumalg commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Fixed Block-scoped variable '...' used before its declaration bug with topologicalSortEntities and topologicalSortNamespaces.

Changed enum conversion from z.number().refine(...).meta({ ... }) to z.enum({ ... }).meta({ "meta:enum": { ... } }). meta:enum is for JSON Schema conversion purpose - without it, we lose information about enum names

{
"ServiceProviderTypeDTOSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "enum": [
      0,
      1,
      2,
    ],
    "meta:enum": {
      "BarberShop": 1,
      "Groomer": 2,
      "Hairdresser": 0,
    },
    "type": "number",
  },
}

before:

const ServiceProviderTypeDTOSchema = z
  .number()
  .refine(val => [0, 1, 2].includes(val), { message: "Invalid enum value" })
  .meta({
    values: { Hairdresser: 0, BarberShop: 1, Groomer: 2 },
    enum: [0, 1, 2],
  })

after:

const ServiceProviderTypeDTOSchema = z
  .enum({ Hairdresser: 0, BarberShop: 1, Groomer: 2 })
  .meta({
    "meta:enum": { Hairdresser: 0, BarberShop: 1, Groomer: 2 },
  })

Enum passed as object allows us to use named enums like ServiceProviderTypeDTOSchema.enum.Hairdresser

@kumalg kumalg changed the title Zod plugin improvments feat: zod plugin improvments Jan 7, 2026
@kumalg kumalg merged commit a699461 into feature/zod-plugin Jan 9, 2026
1 check passed
@kumalg kumalg deleted the feature/zod-plugin-enum-and-json-schema branch January 9, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants