Repository inventory

mx-space/core

Skills indexed from this repository, with install-style signals scoped to the repo.
7 skills3.4K GitHub stars0 weekly installsTypeScriptGitHubOwner profile

Overview

This skill provides a collection of Zod schema patterns and helpers tailored for building DTOs, validation schemas, and request validation in NestJS/TypeScript projects. It captures common patterns such as base schema extensions, custom validators for MongoDB, preprocessing, unions, arrays, nested objects, and mapping schemas to TypeGoose models. Use it to standardize input validation and infer TypeScript types directly from Zod schemas.

How this skill works

The skill exposes reusable Zod patterns and helper validators (e.g., MongoDB ObjectId, non-empty string, unique arrays, pin date) and example schema compositions. You create Zod objects, extend base schemas, or produce DTO classes from schemas to use in controllers and services. It also demonstrates preprocessing, conditional validation, defaults, and mapping between Zod schemas and TypeGoose models for consistent runtime validation and compile-time types.

When to use it

  • Creating request DTOs and validation schemas for NestJS endpoints
  • Defining and reusing project-wide field rules (ObjectId, non-empty strings, unique arrays)
  • Building update DTOs using partial schemas for PATCH/PUT handlers
  • Converting validated data into TypeScript types for services and database models
  • Mapping validation rules to TypeGoose models for Mongoose integration

Best practices

  • Define shared base schemas (write/read bases) and extend them for domain entities
  • Use createZodDto to generate DTO classes for tight NestJS integration
  • Prefer preprocessors to normalize incoming data (empty string -> null, string -> number) before validation
  • Use .partial() to create update DTOs and avoid duplicating field definitions
  • Keep custom validators (zMongoId, zNonEmptyString, zArrayUnique) centralized for consistency

Example use cases

  • Define a PostSchema by extending a WriteBaseSchema to enforce title, slug, category, and optional tags
  • Create MyDto from a Zod schema and derive MyType via z.infer for service method signatures
  • Validate nested user addresses with AddressSchema and an optional addresses array on the UserSchema
  • Preprocess query params converting numeric strings to numbers before validating as numbers
  • Map a Zod schema to a TypeGoose model so required/optional semantics align with Mongoose properties

FAQ

Use createZodDto(MySchema) to produce a DTO class compatible with NestJS controllers.

How can I handle partial updates?

Call MySchema.partial() and wrap it with createZodDto to produce an update DTO where all fields are optional.

7 skills

More from this maintainer
Other repositories and skills published under the same GitHub owner.
Skills library
Jump back to the full directory or explore grouped topics.
Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational