Valibot Repository Structure
Monorepo Layout
valibot/
├── library/ # Core valibot package (zero dependencies)
├── packages/
│ ├── i18n/ # Translated error messages (25+ languages)
│ └── to-json-schema/ # JSON Schema converter
├── codemod/
│ ├── migrate-to-v0.31.0/ # Version migration
│ └── zod-to-valibot/ # Zod converter
├── website/ # valibot.dev (Qwik + Vite)
├── brand/ # Brand assets
├── skills/ # Agent skills (this folder)
└── prompts/ # Legacy AI agent guides
Core Library (/library/src/)
Directory Structure
| Directory |
Purpose |
Examples |
schemas/ |
Data type validators |
string/, object/, array/, union/ |
actions/ |
Validation & transformation |
email/, minLength/, trim/, transform/ |
methods/ |
High-level API |
parse/, safeParse/, pipe/, partial/ |
types/ |
TypeScript definitions |
schema.ts, issue.ts, dataset.ts |
utils/ |
Internal helpers (prefixed _) |
_addIssue/, _stringify/, ValiError/ |
storages/ |
Global state |
Config, message storage |
Schema Categories
- Primitives:
string, number, boolean, bigint, date, symbol, blob, file
- Objects:
object, strictObject, looseObject, objectWithRest
- Arrays:
array, tuple, strictTuple, looseTuple, tupleWithRest
- Advanced:
union, variant, intersect, record, map, set, lazy, custom
- Modifiers:
optional, nullable, nullish, nonNullable, nonNullish, nonOptional
Action Types
Validation (return issues): email, url, uuid, regex, minLength, maxValue, check
Transformation (modify data): trim, toLowerCase, toUpperCase, mapItems, transform
Metadata: brand, flavor, metadata, description, title
File Naming Convention
Each schema/action/method has its own directory:
schemas/string/
├── string.ts # Implementation
├── string.test.ts # Runtime tests
├── string.test-d.ts # Type tests
└── index.ts # Re-export
Core Patterns
Schemas define data types:
export interface StringSchema<TMessage> extends BaseSchema<...> {
readonly kind: 'schema';
readonly type: 'string';
// ...
}
Actions validate/transform in pipelines:
export interface EmailAction<TInput, TMessage> extends BaseValidation<...> {
readonly kind: 'validation';
readonly type: 'email';
// ...
}
Methods provide API functions:
export function parse<TSchema>(
schema: TSchema,
input: unknown
): InferOutput<TSchema>;
Key Types
BaseSchema, BaseValidation, BaseTransformation - Base interfaces
InferOutput<T>, InferInput<T>, InferIssue<T> - Type inference
Config, ErrorMessage<T>, BaseIssue<T> - Configuration and errors
'~standard' property - Standard Schema compatibility
Website (/website/src/routes/)
API Documentation
routes/api/
├── (schemas)/string/ # Schema docs
│ ├── index.mdx # MDX content
│ └── properties.ts # Type definitions
├── (actions)/email/ # Action docs
├── (methods)/parse/ # Method docs
├── (types)/StringSchema/ # Type docs
└── menu.md # Navigation
Guides
routes/guides/
├── (get-started)/ # Intro, installation
├── (main-concepts)/ # Schemas, pipelines, parsing
├── (schemas)/ # Objects, arrays, unions
├── (advanced)/ # Async, i18n, JSON Schema
├── (migration)/ # Version upgrades
└── menu.md # Navigation
Development
Playground
Use library/playground.ts for quick experimentation.
Adding a Schema/Action
- Create directory:
library/src/schemas/yourSchema/
- Create files:
yourSchema.ts, yourSchema.test.ts, yourSchema.test-d.ts, index.ts
- Follow existing patterns (copy similar implementation)
- Export from category
index.ts
- Run
pnpm -C library test
Modifying Core Types
⚠️ Changes to library/src/types/ affect the entire library. Always run full test suite.
Quick Lookups
| Looking for... |
Location |
| Schema implementation |
library/src/schemas/[name]/[name].ts |
| Action implementation |
library/src/actions/[name]/[name].ts |
| Method implementation |
library/src/methods/[name]/[name].ts |
| Type definitions |
library/src/types/ |
| Internal utilities |
library/src/utils/ |
| Error messages (i18n) |
packages/i18n/[lang]/ |
| API docs page |
website/src/routes/api/(category)/[name]/ |
| Guide page |
website/src/routes/guides/(category)/[name]/ |
| Tests |
Same directory as source, .test.ts suffix |
| Type tests |
Same directory as source, .test-d.ts suffix |
Commands
# Library
pnpm -C library build # Build
pnpm -C library test # Run tests
pnpm -C library lint # Lint
pnpm -C library format # Format
# Website
pnpm -C website dev # Dev server
pnpm -C website build # Production build
# Root
pnpm install # Install all
pnpm format # Format all
Key Principles
- Modularity - Small, focused functions; one per file
- Zero dependencies - Core library has no runtime deps
- 100% test coverage - Required for library
- Tree-shakable - Use
// @__NO_SIDE_EFFECTS__ annotation
- Type-safe - Full TypeScript with strict mode
- ESM only - Imports include
.ts extensions
Do's and Don'ts
Do:
- Follow existing code patterns
- Write runtime and type tests
- Add JSDoc documentation
- Keep functions small and focused
- Check bundle size impact
Don't:
- Add external dependencies
- Modify core types without full test run
- Skip tests
- Create large multi-purpose functions
- Modify generated files (
dist/, coverage/)
1---2name: repo-structure-navigate-23description: Navigate the Valibot repository structure. Use when looking for files, understanding the codebase layout, finding schema/action/method implementations, locating tests, API docs, or guide pages. Covers monorepo layout, library architecture, file naming conventions, and quick lookups.4---56# Valibot Repository Structure78## Monorepo Layout910```11valibot/12├── library/ # Core valibot package (zero dependencies)13├── packages/14│ ├── i18n/ # Translated error messages (25+ languages)15│ └── to-json-schema/ # JSON Schema converter16├── codemod/17│ ├── migrate-to-v0.31.0/ # Version migration18│ └── zod-to-valibot/ # Zod converter19├── website/ # valibot.dev (Qwik + Vite)20├── brand/ # Brand assets21├── skills/ # Agent skills (this folder)22└── prompts/ # Legacy AI agent guides23```2425## Core Library (`/library/src/`)2627### Directory Structure2829| Directory | Purpose | Examples |30| ----------- | ------------------------------- | --------------------------------------------- |31| `schemas/` | Data type validators | `string/`, `object/`, `array/`, `union/` |32| `actions/` | Validation & transformation | `email/`, `minLength/`, `trim/`, `transform/` |33| `methods/` | High-level API | `parse/`, `safeParse/`, `pipe/`, `partial/` |34| `types/` | TypeScript definitions | `schema.ts`, `issue.ts`, `dataset.ts` |35| `utils/` | Internal helpers (prefixed `_`) | `_addIssue/`, `_stringify/`, `ValiError/` |36| `storages/` | Global state | Config, message storage |3738### Schema Categories3940- **Primitives**: `string`, `number`, `boolean`, `bigint`, `date`, `symbol`, `blob`, `file`41- **Objects**: `object`, `strictObject`, `looseObject`, `objectWithRest`42- **Arrays**: `array`, `tuple`, `strictTuple`, `looseTuple`, `tupleWithRest`43- **Advanced**: `union`, `variant`, `intersect`, `record`, `map`, `set`, `lazy`, `custom`44- **Modifiers**: `optional`, `nullable`, `nullish`, `nonNullable`, `nonNullish`, `nonOptional`4546### Action Types4748**Validation** (return issues): `email`, `url`, `uuid`, `regex`, `minLength`, `maxValue`, `check`4950**Transformation** (modify data): `trim`, `toLowerCase`, `toUpperCase`, `mapItems`, `transform`5152**Metadata**: `brand`, `flavor`, `metadata`, `description`, `title`5354### File Naming Convention5556Each schema/action/method has its own directory:5758```59schemas/string/60├── string.ts # Implementation61├── string.test.ts # Runtime tests62├── string.test-d.ts # Type tests63└── index.ts # Re-export64```6566### Core Patterns6768**Schemas** define data types:6970```typescript71export interface StringSchema<TMessage> extends BaseSchema<...> {72 readonly kind: 'schema';73 readonly type: 'string';74 // ...75}76```7778**Actions** validate/transform in pipelines:7980```typescript81export interface EmailAction<TInput, TMessage> extends BaseValidation<...> {82 readonly kind: 'validation';83 readonly type: 'email';84 // ...85}86```8788**Methods** provide API functions:8990```typescript91export function parse<TSchema>(92 schema: TSchema,93 input: unknown94): InferOutput<TSchema>;95```9697### Key Types9899- `BaseSchema`, `BaseValidation`, `BaseTransformation` - Base interfaces100- `InferOutput<T>`, `InferInput<T>`, `InferIssue<T>` - Type inference101- `Config`, `ErrorMessage<T>`, `BaseIssue<T>` - Configuration and errors102- `'~standard'` property - [Standard Schema](https://github.com/standard-schema/standard-schema) compatibility103104## Website (`/website/src/routes/`)105106### API Documentation107108```109routes/api/110├── (schemas)/string/ # Schema docs111│ ├── index.mdx # MDX content112│ └── properties.ts # Type definitions113├── (actions)/email/ # Action docs114├── (methods)/parse/ # Method docs115├── (types)/StringSchema/ # Type docs116└── menu.md # Navigation117```118119### Guides120121```122routes/guides/123├── (get-started)/ # Intro, installation124├── (main-concepts)/ # Schemas, pipelines, parsing125├── (schemas)/ # Objects, arrays, unions126├── (advanced)/ # Async, i18n, JSON Schema127├── (migration)/ # Version upgrades128└── menu.md # Navigation129```130131## Development132133### Playground134135Use `library/playground.ts` for quick experimentation.136137### Adding a Schema/Action1381391. Create directory: `library/src/schemas/yourSchema/`1402. Create files: `yourSchema.ts`, `yourSchema.test.ts`, `yourSchema.test-d.ts`, `index.ts`1413. Follow existing patterns (copy similar implementation)1424. Export from category `index.ts`1435. Run `pnpm -C library test`144145### Modifying Core Types146147⚠️ Changes to `library/src/types/` affect the entire library. Always run full test suite.148149## Quick Lookups150151| Looking for... | Location |152| --------------------- | ---------------------------------------------- |153| Schema implementation | `library/src/schemas/[name]/[name].ts` |154| Action implementation | `library/src/actions/[name]/[name].ts` |155| Method implementation | `library/src/methods/[name]/[name].ts` |156| Type definitions | `library/src/types/` |157| Internal utilities | `library/src/utils/` |158| Error messages (i18n) | `packages/i18n/[lang]/` |159| API docs page | `website/src/routes/api/(category)/[name]/` |160| Guide page | `website/src/routes/guides/(category)/[name]/` |161| Tests | Same directory as source, `.test.ts` suffix |162| Type tests | Same directory as source, `.test-d.ts` suffix |163164## Commands165166```bash167# Library168pnpm -C library build # Build169pnpm -C library test # Run tests170pnpm -C library lint # Lint171pnpm -C library format # Format172173# Website174pnpm -C website dev # Dev server175pnpm -C website build # Production build176177# Root178pnpm install # Install all179pnpm format # Format all180```181182## Key Principles1831841. **Modularity** - Small, focused functions; one per file1852. **Zero dependencies** - Core library has no runtime deps1863. **100% test coverage** - Required for library1874. **Tree-shakable** - Use `// @__NO_SIDE_EFFECTS__` annotation1885. **Type-safe** - Full TypeScript with strict mode1896. **ESM only** - Imports include `.ts` extensions190191## Do's and Don'ts192193**Do:**194195- Follow existing code patterns196- Write runtime and type tests197- Add JSDoc documentation198- Keep functions small and focused199- Check bundle size impact200201**Don't:**202203- Add external dependencies204- Modify core types without full test run205- Skip tests206- Create large multi-purpose functions207- Modify generated files (`dist/`, `coverage/`)