Package Exports
- @ariestools/zod
- @ariestools/zod/model
- @ariestools/zod/package.json
Readme
Deprecated. Use
@ariestools/sdk/zodinstead. This package is a backward-compatibility re-export shim.
@ariestools/zod
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Install
Using npm:
npm install {{name}}Using yarn:
yarn add {{name}}Using pnpm:
pnpm add {{name}}Using bun:
bun add {{name}}License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
zod
### .temp-typedoc
### functions
### <a id="zodAllFactory"></a>zodAllFactory
function zodAllFactory<T, TName>(zod, name): object;Alpha
Creates a bundle of is, as, and to factory functions for a given zod schema.
Type Parameters
T
T
TName
TName extends string
Parameters
zod
ZodType<T>
The zod schema to validate against
name
TName
The name used to suffix the generated function names (e.g. 'Address' produces isAddress, asAddress, toAddress)
Returns
object
An object containing is<Name>, as<Name>, and to<Name> functions
### <a id="zodAsAsyncFactory"></a>zodAsAsyncFactory
function zodAsAsyncFactory<TZod>(zod, name): {
<T> (value): Promise<T & TZod | undefined>;
<T> (value, assert): Promise<T & TZod>;
};Creates an async function that validates a value against a zod schema and returns it with a narrowed type.
Uses safeParseAsync for schemas with async refinements. When called without an assert config, returns undefined on failure.
Type Parameters
TZod
TZod
Parameters
zod
ZodType<TZod>
The zod schema to validate against
name
string
A name used in error messages for identification
Returns
An async function that validates and narrows the type of a value
{
<T> (value): Promise<T & TZod | undefined>;
<T> (value, assert): Promise<T & TZod>;
}
### <a id="zodAsFactory"></a>zodAsFactory
function zodAsFactory<TZod>(zod, name): {
<T> (value): T & TZod | undefined;
<T> (value, assert): T & TZod;
};Creates a function that validates a value against a zod schema and returns it with a narrowed type. When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure.
Type Parameters
TZod
TZod
Parameters
zod
ZodType<TZod>
The zod schema to validate against
name
string
A name used in error messages for identification
Returns
A function that validates and narrows the type of a value
{
<T> (value): T & TZod | undefined;
<T> (value, assert): T & TZod;
}
### <a id="zodIsFactory"></a>zodIsFactory
function zodIsFactory<TZod>(zod): <T>(value) => value is T & TZod;Creates a type guard function that checks if a value matches a zod schema.
Type Parameters
TZod
TZod
Parameters
zod
ZodType<TZod>
The zod schema to validate against
Returns
A type guard function that returns true if the value passes validation
<T>(value) => value is T & TZod
### <a id="zodToAsyncFactory"></a>zodToAsyncFactory
function zodToAsyncFactory<TZod>(zod, name): {
<T> (value): Promise<T & TZod | undefined>;
<T> (value, assert): Promise<T & TZod>;
};Creates an async function that converts a value to the zod schema type, delegating to zodAsAsyncFactory internally.
Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure.
Type Parameters
TZod
TZod
Parameters
zod
ZodType<TZod>
The zod schema to validate against
name
string
A name used in error messages for identification
Returns
An async function that validates and converts a value to the schema type
{
<T> (value): Promise<T & TZod | undefined>;
<T> (value, assert): Promise<T & TZod>;
}
### <a id="zodToFactory"></a>zodToFactory
function zodToFactory<TZod>(zod, name): {
<T> (value): T & TZod | undefined;
<T> (value, assert): T & TZod;
};Creates a function that converts a value to the zod schema type, delegating to zodAsFactory internally.
Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure.
Type Parameters
TZod
TZod
Parameters
zod
ZodType<TZod>
The zod schema to validate against
name
string
A name used in error messages for identification
Returns
A function that validates and converts a value to the schema type
{
<T> (value): T & TZod | undefined;
<T> (value, assert): T & TZod;
}
### interfaces
### <a id="ZodFactoryConfigObject"></a>ZodFactoryConfigObject
Configuration object for zod factory functions, providing a name for error messages.
Properties
name
name: string; ### type-aliases
### <a id="AllZodFactories"></a>AllZodFactories
type AllZodFactories<TType, TName> = Record<`is${TName}`, ReturnType<typeof zodIsFactory>> & Record<`as${TName}`, ReturnType<typeof zodAsFactory>> & Record<`to${TName}`, ReturnType<typeof zodToFactory>>;Alpha
Type Parameters
TType
TType
TName
TName extends string
### <a id="ZodFactoryConfig"></a>ZodFactoryConfig
type ZodFactoryConfig =
| AssertConfig
| ZodFactoryConfigObject;Configuration for zod factory assertion behavior, either an AssertConfig or a named config object.