JSPM

@ariestools/zod

8.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 728
  • Score
    100M100P100Q11091F
  • License LGPL-3.0-only

DEPRECATED — use @ariestools/sdk/zod. Backward-compatibility re-export shim.

Package Exports

  • @ariestools/zod
  • @ariestools/zod/model
  • @ariestools/zod/package.json

Readme

Deprecated. Use @ariestools/sdk/zod instead. This package is a backward-compatibility re-export shim.

logo

@ariestools/zod

npm license

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

@ariestools/zod


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

@ariestools/zod


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

@ariestools/zod


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

@ariestools/zod


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

@ariestools/zod


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

@ariestools/zod


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

@ariestools/zod


Configuration object for zod factory functions, providing a name for error messages.

Properties

name

name: string;
  ### type-aliases

    ### <a id="AllZodFactories"></a>AllZodFactories

@ariestools/zod


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

@ariestools/zod


type ZodFactoryConfig = 
  | AssertConfig
  | ZodFactoryConfigObject;

Configuration for zod factory assertion behavior, either an AssertConfig or a named config object.

Credits

Made with 🔥 and ❄️ by XY Labs