### New user fallbacks example Source: https://valibot.dev/api/getFallbacksAsync.md Example showing how to get fallback values for a new user schema. The schema uses objectAsync with a fallbackAsync for the username field, and the result is a Promise that resolves to an object with the fallback values. ```ts import { getAnyUniqueUsername, isUsernameUnique } from '~/api'; const NewUserSchema = v.objectAsync({ username: v.fallbackAsync( v.pipeAsync(v.string(), v.minLength(3), v.checkAsync(isUsernameUnique)), getAnyUniqueUsername ), password: v.pipe(v.string(), v.minLength(8)), }); const fallbackValues = await v.getFallbacksAsync(NewUserSchema); /* { username: "cookieMonster07", password: undefined } */ ``` -------------------------------- ### examples(examples_) Source: https://valibot.dev/api/examples/ Creates an examples metadata action that attaches example values to a schema. Useful for documentation and AI tools. ```APIDOC ## examples(examples_) ### Description Creates an examples metadata action that attaches example values to a schema. Useful for documentation and AI tools. ### Method N/A (SDK function) ### Endpoint N/A (SDK function) ### Parameters #### Generics - **TInput** (type) - Required - The input type of the schema. - **TExamples** (type) - Required - The type of the examples array, must be a readonly array of TInput. #### Parameters - **examples_** (TExamples) - Required - An array of example values. ### Returns - **Action** (ExamplesAction) - The created examples action. ### Examples #### String schema ```js const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz'])); ``` #### Number schema ```js const NumberSchema = v.pipe(v.number(), v.examples([1, 2, 3])); ``` ### Compatible APIs - **Schemas**: any, array, bigint, blob, boolean, custom, date, enum, exactOptional, file, function, instance, intersect, lazy, literal, looseObject, looseTuple, map, nan, never, nonNullable, nonNullish, nonOptional, null, nullable, nullish, number, object, objectWithRest, optional, picklist, promise, record, set, strictObject, strictTuple, string, symbol, tuple, tupleWithRest, undefined, undefinedable, union, unknown, variant, void - **Methods**: getExamples, pipe - **Utils**: isOfKind, isOfType ``` -------------------------------- ### Attach examples to a schema with v.examples() and extract with v.getExamples() Source: https://valibot.dev/blog/valibot-v1.2-release-notes/ Shows how to attach example values to schema fields using v.examples() and retrieve them with v.getExamples(). Multiple examples() actions in a pipeline are concatenated via depth-first search, providing a complete list of examples for AI tool integration, documentation, or test fixtures. ```typescript import * as v from 'valibot'; const UserSchema = v.object({ id: v.pipe( v.string(), v.uuid(), v.examples(['550e8400-e29b-41d4-a716-446655440000']) ), name: v.pipe( v.string(), v.nonEmpty(), v.examples(['Alice Smith', 'Bob Johnson']) ), email: v.pipe( v.string(), v.email(), v.examples(['alice@example.com', 'bob@example.com']) ), }); // Extract email examples const emailExamples = v.getExamples(UserSchema.entries.email); ``` -------------------------------- ### examples Source: https://valibot.dev/api/examples.md Creates an examples metadata action that attaches example values to a schema. This is useful for documentation purposes and when working with AI tools. ```APIDOC ## examples ### Description Creates an examples metadata action that attaches example values to a schema. This is useful for documentation purposes and when working with AI tools. ### Signature ```ts const Action = v.examples(examples_); ``` ### Generics - `TInput` `extends any` - `TExamples` `extends readonly TInput[]` ### Parameters - `examples_` `TExamples` - The example values to attach to the schema. ### Returns - `Action` `ExamplesAction` - The examples action. ### Examples #### String schema Schema to validate a string with examples. ```ts const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz'])); ``` #### Number schema Schema to validate a number with examples. ```ts const NumberSchema = v.pipe(v.number(), v.examples([1, 2, 3])); ``` ### Related The following APIs can be combined with `examples`. #### Schemas [`any`](/api/any.md), [`array`](/api/array.md), [`bigint`](/api/bigint.md), [`blob`](/api/blob.md), [`boolean`](/api/boolean.md), [`custom`](/api/custom.md), [`date`](/api/date.md), [`enum`](/api/enum.md), [`exactOptional`](/api/exactOptional.md), [`file`](/api/file.md), [`function`](/api/function.md), [`instance`](/api/instance.md), [`intersect`](/api/intersect.md), [`lazy`](/api/lazy.md), [`literal`](/api/literal.md), [`looseObject`](/api/looseObject.md), [`looseTuple`](/api/looseTuple.md), [`map`](/api/map.md), [`nan`](/api/nan.md), [`never`](/api/never.md), [`nonNullable`](/api/nonNullable.md), [`nonNullish`](/api/nonNullish.md), [`nonOptional`](/api/nonOptional.md), [`null`](/api/null.md), [`nullable`](/api/nullable.md), [`nullish`](/api/nullish.md), [`number`](/api/number.md), [`object`](/api/object.md), [`objectWithRest`](/api/objectWithRest.md), [`optional`](/api/optional.md), [`picklist`](/api/picklist.md), [`promise`](/api/promise.md), [`record`](/api/record.md), [`set`](/api/set.md), [`strictObject`](/api/strictObject.md), [`strictTuple`](/api/strictTuple.md), [`string`](/api/string.md), [`symbol`](/api/symbol.md), [`tuple`](/api/tuple.md), [`tupleWithRest`](/api/tupleWithRest.md), [`undefined`](/api/undefined.md), [`undefinedable`](/api/undefinedable.md), [`union`](/api/union.md), [`unknown`](/api/unknown.md), [`variant`](/api/variant.md), [`void`](/api/void.md) #### Methods [`getExamples`](/api/getExamples.md), [`pipe`](/api/pipe.md) #### Utils [`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md) ``` -------------------------------- ### Get Dot Path Example Source: https://valibot.dev/guides/issues/ Example of using v.getDotPath(issue) to create a dot path from an issue. Requires importing Valibot as v. ```typescript import * as v from 'valibot'; const dotPath = v.getDotPath(issue); ``` -------------------------------- ### getExamples Source: https://valibot.dev/api/getExamples.md Returns the examples defined on a schema. If multiple examples are defined, they are concatenated using depth-first search. If no examples are defined, an empty array is returned. ```APIDOC ## getExamples ### Description Returns the examples of the schema. If multiple examples are defined, it concatenates them using depth-first search. If no examples are defined, an empty array is returned. ### Method Function ### Endpoint `v.getExamples(schema)` ### Parameters - `schema` (TSchema) - Required - The schema to retrieve examples from. ### Returns - `examples` (InferExamples) - The examples defined on the schema. ### Generics - `TSchema` extends `BaseSchema> | BaseSchemaAsync>` ### Examples #### String schema ```ts const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz'])); const examples = v.getExamples(StringSchema); // ['foo', 'bar', 'baz'] ``` #### Nested schema ```ts const NestedSchema = v.pipe( v.string(), v.examples(['foo', 'bar', 'baz']), v.pipe(v.string(), v.examples(['qux', 'quux'])) ); const examples = v.getExamples(NestedSchema); // ['foo', 'bar', 'baz', 'qux', 'quux'] ``` ``` -------------------------------- ### getExamples with string schema Source: https://valibot.dev/api/getExamples.md Example of using `getExamples` on a string schema with three examples, returning the array ['foo', 'bar', 'baz']. ```ts const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz'])); const examples = v.getExamples(StringSchema); // ['foo', 'bar', 'baz'] ``` -------------------------------- ### Date schema example Source: https://valibot.dev/api/toDate.md Example schema that validates a string and transforms it to a date using `v.pipe` and `v.toDate`. ```ts const DateSchema = v.pipe(v.string(), v.toDate()); ``` -------------------------------- ### ExamplesAction Source: https://valibot.dev/api/ExamplesAction.md ExamplesAction is a metadata action that attaches example values to a schema. It extends BaseMetadata and includes a type, reference, and examples property. ```APIDOC ## ExamplesAction ### Description Examples metadata action. ### Generics - `TInput` extends `any` - `TExamples` extends `readonly TInput[]` ### Definition - `ExamplesAction` extends `BaseMetadata` - `type` `'examples'` - `reference` `typeof examples` - `examples` `TExamples` ### Related #### Schemas - `any` - `array` - `bigint` - `blob` - `boolean` - `custom` - `date` - `enum` - `exactOptional` - `file` - `function` - `instance` - `intersect` - `lazy` - `literal` - `looseObject` - `looseTuple` - `map` - `nan` - `never` - `nonNullable` - `nonNullish` - `nonOptional` - `null` - `nullable` - `nullish` - `number` - `object` - `objectWithRest` - `optional` - `picklist` - `promise` - `record` - `set` - `strictObject` - `strictTuple` - `string` - `symbol` - `tuple` - `tupleWithRest` - `undefined` - `undefinedable` - `union` - `unknown` - `variant` - `void` #### Methods - `getExamples` - `pipe` #### Actions - `examples` ``` -------------------------------- ### String schema with examples Source: https://valibot.dev/api/examples.md Schema to validate a string with examples. Uses `v.pipe` with `v.string()` and `v.examples(['foo', 'bar', 'baz'])`. ```TypeScript const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz'])); ``` -------------------------------- ### 64-bit MAC Schema Example Source: https://valibot.dev/api/mac64/ Example of using mac64 within a Valibot schema to validate a 64-bit MAC address, with a custom error message. ```typescript const Mac64Schema = v.pipe( v.string(), v.mac64('The MAC address is badly formatted.') ); ``` -------------------------------- ### 48-bit MAC Schema Example Source: https://valibot.dev/api/mac48/ Example schema that validates a string as a 48-bit MAC address, using a custom error message. ```typescript const Mac48Schema = v.pipe( v.string(), v.mac48('The MAC address is badly formatted.') ); ``` -------------------------------- ### Number schema example with v.pipe and v.string Source: https://valibot.dev/api/toNumber.md Example of using `toNumber` in a pipeline with `v.string()` to validate a string and transform it to a number. ```ts const NumberSchema = v.pipe(v.string(), v.toNumber()); ``` -------------------------------- ### HTTPS URL schema example Source: https://valibot.dev/api/startsWith.md Example schema that validates a string is a URL and starts with 'https://'. ```ts const HttpsUrlSchema = v.pipe(v.string(), v.url(), v.startsWith('https://')); ``` -------------------------------- ### Tuple fallbacks example Source: https://valibot.dev/api/getFallbacks.md Get the fallback values of a tuple schema. The result is [100]. ```ts const TupleSchema = v.tuple([v.fallback(v.number(), 100)]); const fallbackValues = v.getFallbacks(TupleSchema); // [100] ``` -------------------------------- ### Install Valibot skill via npx Source: https://valibot.dev/blog/making-valibot-easier-for-coding-agents/ Run this command to install the Valibot skill from the open-circle/agent-skills repository. The skill is also published at /.well-known/agent-skills/valibot/SKILL.md. ```bash npx skills add open-circle/agent-skills --skill valibot ``` -------------------------------- ### Tuple defaults example Source: https://valibot.dev/api/getDefaults.md Get the default values of a tuple schema. The nullable number with a default returns 100. ```ts const TupleSchema = v.tuple([v.nullable(v.number(), 100)]); const defaultValues = v.getDefaults(TupleSchema); // [100] ``` -------------------------------- ### Optional string schema example Source: https://valibot.dev/api/getDefault.md Gets the default value from an optional string schema with a custom default string. ```ts const OptionalStringSchema = v.optional(v.string(), "I'm the default!"); const defaultValue = v.getDefault(OptionalStringSchema); // "I'm the default!" ``` -------------------------------- ### examples action signature Source: https://valibot.dev/api/examples.md Creates an examples metadata action. The generic `TInput` extends `any` and `TExamples` extends `readonly TInput[]`. The parameter `examples_` is of type `TExamples`. Returns an `ExamplesAction`. ```TypeScript const Action = v.examples(examples_); ``` -------------------------------- ### Object fallbacks example Source: https://valibot.dev/api/getFallbacks.md Get the fallback values of an object schema. The result is { key: "I'm the fallback!" }. ```ts const ObjectSchema = v.object({ key: v.fallback(v.string(), "I'm the fallback!"), }); const fallbackValues = v.getFallbacks(ObjectSchema); // { key: "I'm the fallback!" } ``` -------------------------------- ### Install Valibot from npm using various package managers Source: https://valibot.dev/guides/installation/ Commands to install Valibot for Node and Bun using npm, yarn, pnpm, or bun. ```bash npm install valibot # npm yarn add valibot # yarn pnpm add valibot # pnpm bun add valibot # bun ``` -------------------------------- ### Object defaults example Source: https://valibot.dev/api/getDefaults.md Get the default values of an object schema. The optional field with a default returns the default string. ```ts const ObjectSchema = v.object({ key: v.optional(v.string(), "I'm the default!"), }); const defaultValues = v.getDefaults(ObjectSchema); // { key: "I'm the default!" } ``` -------------------------------- ### Import Valibot from deno.land/x Source: https://valibot.dev/guides/installation/ Reference Valibot directly through the deno.land/x URL in Deno. ```javascript // With individual imports import { … } from 'https://deno.land/x/valibot/mod.ts'; // With a wildcard import import * as v from 'https://deno.land/x/valibot/mod.ts'; ``` -------------------------------- ### Date schema example Source: https://valibot.dev/api/notValue/ Schema to validate a date that is before or after the start of 2000. Uses v.pipe with v.date() and v.notValue(new Date('2000-01-01'), ...). ```typescript const DateSchema = v.pipe( v.date(), v.notValue(new Date('2000-01-01'), 'The date must not be the start of 2000.') ); ``` -------------------------------- ### Sum all numbers with reduceItems Source: https://valibot.dev/api/reduceItems/ Example schema that sums all numbers in an array using v.pipe and v.reduceItems. The operation adds each item to the accumulated sum, starting from 0. ```typescript const SumArraySchema = v.pipe( v.array(v.number()), v.reduceItems((sum, item) => sum + item, 0) ); ``` -------------------------------- ### Example usage of v.parser Source: https://valibot.dev/api/parser.md Demonstrates creating a parser for an email schema and parsing a string. The example wraps the call in a try/catch to handle errors, logging them to the console. ```ts try { const EmailSchema = v.pipe(v.string(), v.email()); const emailParser = v.parser(EmailSchema); const email = emailParser('jane@example.com'); // Handle errors if one occurs } catch (error) { console.log(error); } ``` -------------------------------- ### Install Valibot from JSR using various package managers Source: https://valibot.dev/guides/installation/ Commands to install Valibot from JSR for Node, Deno, and Bun using deno, npm, yarn, pnpm, or bun. ```bash deno add jsr:@valibot/valibot # deno npx jsr add @valibot/valibot # npm yarn dlx jsr add @valibot/valibot # yarn pnpm dlx jsr add @valibot/valibot # pnpm bunx jsr add @valibot/valibot # bun ``` -------------------------------- ### Unwrap optional schema Source: https://valibot.dev/api/optional.md Use `v.unwrap` to undo the effect of `optional`. The example creates an optional number schema and then unwraps it to get the original number schema. ```ts const OptionalNumberSchema = v.optional(v.number()); const NumberSchema = v.unwrap(OptionalNumberSchema); ``` -------------------------------- ### getExamples with nested schema Source: https://valibot.dev/api/getExamples.md Example of using `getExamples` on a nested schema, concatenating examples from both levels using depth-first search, returning ['foo', 'bar', 'baz', 'qux', 'quux']. ```ts const NestedSchema = v.pipe( v.string(), v.examples(['foo', 'bar', 'baz']), v.pipe(v.string(), v.examples(['qux', 'quux'])) ); const examples = v.getExamples(NestedSchema); // ['foo', 'bar', 'baz', 'qux', 'quux'] ``` -------------------------------- ### Unwrap an optional string schema Source: https://valibot.dev/api/unwrap.md Demonstrates unwrapping an optional string schema. The example creates an optional string schema and then unwraps it to get the underlying string schema. ```TypeScript const OptionalStringSchema = v.optional(v.string()); const StringSchema = v.unwrap(OptionalStringSchema); ``` -------------------------------- ### Infer object output type with InferObjectOutput Source: https://valibot.dev/api/InferObjectOutput/ Use InferObjectOutput to get the output type of object entries. The example creates entries with a string transformed to its length, and the inferred type is { key: number }. ```typescript // Create object entries const entries = { key: v.pipe( v.string(), v.transform((input) => input.length) ), }; // Infer entries output type type EntriesOutput = v.InferObjectOutput; // { key: number } ``` -------------------------------- ### Define a schema with v.object Source: https://valibot.dev/guides/mental-model.md Schemas are the starting point for using Valibot. This example defines a BookSchema with title, numberOfPages, publication, and tags fields, demonstrating nesting of schemas like v.string, v.number, v.date, and v.array. ```TypeScript import * as v from 'valibot'; const BookSchema = v.object({ title: v.string(), numberOfPages: v.number(), publication: v.date(), tags: v.array(v.string()), }); ``` -------------------------------- ### Clone, bundle, and play with the new Valibot source code Source: https://valibot.dev/blog/first-draft-of-the-new-pipe-function/ Commands to clone the repository, switch to the rewrite-with-pipe branch, install dependencies, build the library, and run the playground. Modify playground.ts before running pnpm play. ```bash # Clone repository git clone git@github.com:open-circle/valibot.git # Switch branch git switch rewrite-with-pipe # Install dependencies cd ./valibot && pnpm install # Bundle library cd ./library && pnpm build # Modify `playground.ts` # Run playground pnpm play ``` -------------------------------- ### Infer and format Valibot schema issues Source: https://valibot.dev/blog/why-migrate-to-valibot/ Use InferIssue to get the precise issue type for a schema and format it based on the issue kind. The example shows a schema for an email and a function that returns a message for schema or action issues. ```typescript import * as v from 'valibot'; const EmailSchema = v.pipe(v.string(), v.email()); type EmailIssue = v.InferIssue; function formatIssue(issue: EmailIssue) { if (issue.kind === 'schema') { return `Expected ${issue.expected} but received ${issue.received}.`; } return `Invalid email address: ${issue.received}.`; } ``` -------------------------------- ### Donation schema defaults example Source: https://valibot.dev/api/getDefaultsAsync/ Defines an async object schema with optional fields and uses `getDefaultsAsync` to get the default values. The output shows the resolved defaults, including a generated UUID and `undefined` for a field without a default. ```typescript import { getRandomOrgId } from '~/api'; const DonationSchema = v.objectAsync({ timestamp: v.optional(v.date(), () => new Date()), sponsor: v.optional(v.pipe(v.string(), v.nonEmpty()), 'anonymous'), organizationId: v.optionalAsync(v.pipe(v.string(), v.uuid()), getRandomOrgId), message: v.optional(v.pipe(v.string(), v.minLength(1))), }); const defaultValues = await v.getDefaultsAsync(DonationSchema); /* { timestamp: new Date(), sponsor: "anonymous", organizationId: "43775869-95f3-4e00-9f37-161ec8f9f7cd", message: undefined } */ ``` -------------------------------- ### Branded fruit schema example Source: https://valibot.dev/api/brand.md Shows how to use `brand` to create a branded schema and infer its output type. The example demonstrates that a parsed value is accepted, while a plain object causes a type error. ```ts // Create schema and infer output type const FruitSchema = v.pipe(v.object({ name: v.string() }), v.brand('Fruit')); type FruitOutput = v.InferOutput; // This works because output is branded const apple: FruitOutput = v.parse(FruitSchema, { name: 'apple' }); // But this will result in a type error const banana: FruitOutput = { name: 'banana' }; ``` -------------------------------- ### Register schema example using forward Source: https://valibot.dev/api/forward.md Example schema that ensures two passwords match. It uses `v.forward` with `v.partialCheck` to forward the validation error to the `password2` field. ```ts const RegisterSchema = v.pipe( v.object({ email: v.pipe( v.string(), v.nonEmpty('Please enter your email.'), v.email('The email address is badly formatted.') ), password1: v.pipe( v.string(), v.nonEmpty('Please enter your password.'), v.minLength(8, 'Your password must have 8 characters or more.') ), password2: v.string(), }), v.forward( v.partialCheck( [['password1'], ['password2']], (input) => input.password1 === input.password2, 'The two passwords do not match.' ), ['password2'] ) ); ``` -------------------------------- ### partialAsync usage example Source: https://valibot.dev/api/partialAsync.md Shows the basic usage of v.partialAsync with generic type parameters TSchema and TKeys, taking a schema and optional keys. ```TypeScript const Schema = v.partialAsync(schema, keys); ``` -------------------------------- ### safeParser usage example Source: https://valibot.dev/api/safeParser.md Demonstrates creating a safe parser for an email schema and parsing an input. The result is checked for success, and the output or issues are handled accordingly. ```ts const EmailSchema = v.pipe(v.string(), v.email()); const safeEmailParser = v.safeParser(EmailSchema); const result = safeEmailParser('jane@example.com'); if (result.success) { const email = result.output; } else { console.log(result.issues); } ``` -------------------------------- ### ExamplesAction Definition Source: https://valibot.dev/api/ExamplesAction/ Defines the ExamplesAction type, its generics, and its properties. This is a type-level definition for the action. ```APIDOC ## ExamplesAction ### Description Defines the ExamplesAction metadata action, which attaches example values to a schema. ### Generics - `TInput` extends `any` - `TExamples` extends `readonly TInput[]` ### Definition - `ExamplesAction` extends `BaseMetadata` - `type`: `'examples'` - `reference`: `typeof examples` - `examples`: `TExamples` ### Compatible APIs #### Schemas - `any`, `array`, `bigint`, `blob`, `boolean`, `custom`, `date`, `enum`, `exactOptional`, `file`, `function`, `instance`, `intersect`, `lazy`, `literal`, `looseObject`, `looseTuple`, `map`, `nan`, `never`, `nonNullable`, `nonNullish`, `nonOptional`, `null`, `nullable`, `nullish`, `number`, `object`, `objectWithRest`, `optional`, `picklist`, `promise`, `record`, `set`, `strictObject`, `strictTuple`, `string`, `symbol`, `tuple`, `tupleWithRest`, `undefined`, `undefinedable`, `union`, `unknown`, `variant`, `void` #### Methods - `getExamples`, `pipe` #### Actions - `examples` ``` -------------------------------- ### Run the Valibot codemod locally Source: https://valibot.dev/guides/migrate-from-zod.md Use npx @valibot/zod-to-valibot to preview changes with --dry or apply them to your codebase. ```bash // Preview changes (no writes) npx @valibot/zod-to-valibot src/**/* --dry // Apply changes npx @valibot/zod-to-valibot src/**/* ``` -------------------------------- ### Hexadecimal schema example Source: https://valibot.dev/api/hexadecimal/ Example schema that validates a string is hexadecimal, using a custom error message. ```typescript const HexadecimalSchema = v.pipe( v.string(), v.hexadecimal('The hexadecimal is badly formatted.') ); ``` -------------------------------- ### Cache schema example Source: https://valibot.dev/api/cacheAsync.md Creates a schema that caches its output with default settings. ```ts const CacheSchema = v.cacheAsync(v.string()); ``` -------------------------------- ### flatten usage example Source: https://valibot.dev/api/flatten/ Example of using flatten with safeParse to flatten error messages from a schema validation. ```typescript const Schema = v.object({ nested: v.object({ foo: v.string('Value of "nested.foo" is invalid.'), }), }); const result = v.safeParse(Schema, { nested: { foo: null } }); if (result.issues) { const flatErrors = v.flatten(result.issues); // ... } ``` -------------------------------- ### Emoji schema example Source: https://valibot.dev/api/emoji.md Example schema that validates a string is an emoji, using a custom error message. ```TypeScript const EmojiSchema = v.pipe( v.string(), v.emoji('Please provide a valid emoji.') ); ``` -------------------------------- ### Pixel string schema example Source: https://valibot.dev/api/custom/ Example of using custom to validate a pixel string with a regular expression. ```typescript const PixelStringSchema = v.custom<`${number}px`>((input) => typeof input === 'string' ? /^\d+px$/.test(input) : false ); ``` -------------------------------- ### Create registry with schema identification and transform unknown data Source: https://valibot.dev/blog/same-data-different-shapes/ Use createRegistry with an identify configuration that uses match.field and match.fields to detect the source schema. Then call identifyAndTransform to transform unknown data, returning a result with the transformed value and metadata about the detected schema and route. ```javascript import { createRegistry, match } from 'dobajs'; const registry = createRegistry({ schemas: { database: databaseUser, frontend: frontendUser, ai: aiUser }, migrations: { // ...same as before }, identify: { database: match.field('passwordHash'), frontend: match.fields('createdAt', 'settings'), ai: match.field('hasNotifications'), }, }); const result = await registry.identifyAndTransform(unknownData, 'ai'); if (result.ok) { result.value; // transformed data result.meta.from; // which schema it detected result.meta.path; // the route it took, e.g. ['database', 'ai'] } ```