Libraries
    Preparing search index...

    Class ObjectSchemaBuilder<TProperties, TRequired, TNullable, TExplicitType, THasDefault, TExtensions, TConstructorSchemas>

    Object schema builder class. Similar to the object type in JS. Allows to define a schema for object value. Should be used to validate objects with specific properties. Properties should be defined as their own schema builders. You can use any SchemaBuilder e.g. string(), number(), boolean(), array(), object(), etc. to define properties. Which means that you can define nested objects and arrays of any complexity.

    NOTE this class is exported only to give opportunity to extend it by inheriting. It is not recommended to create an instance of this class directly. Use object() function instead.

    const schema = object({
    name: string(),
    age: number()
    });

    const result = schema.validate({
    name: 'John',
    age: 30
    });

    // result.valid === true
    // result.object === { name: 'John', age: 30 }
    const schema = object({
    name: string(),
    age: number().optional()
    });

    const result = schema.validate({
    name: 'John'
    });
    // result.valid === true
    // result.object === { name: 'John' }
    const schema = object({
    name: string(),
    age: number();
    });
    const result = schema.validate({
    name: 'John'
    });

    // result.valid === false
    // result.errors is deprecated — use result.getErrorsFor() instead
    // result.getErrorsFor((p) => p.age).errors // ["is expected to have property 'age'"]
    const schema = object({
    name: string(),
    address: object({
    city: string(),
    country: string()
    })
    });
    const result = schema.validate({
    name: 'John',
    address: {
    city: 'New York',
    country: 'USA'
    }
    });
    // result.valid === true
    // result.object === {
    // name: 'John',
    // address: {
    // city: 'New York',
    // country: 'USA'
    // }
    // }

    object

    Type Parameters

    • TProperties extends Record<string, SchemaBuilder<any, any, any, any, any>> = {}
    • TRequired extends boolean = true
    • TNullable extends boolean = false
    • TExplicitType = undefined
    • THasDefault extends boolean = false
    • TExtensions = {}
    • TConstructorSchemas extends SchemaBuilder<any, any, any, any, any>[] = []

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    "[___hasDefault]": THasDefault

    Type-level brand encoding whether this schema has a default value. Not emitted at runtime — used by input type inference.

    "[___type]": TRequired extends true
        ? TNullable extends true
            ? | (
                undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | null
            : undefined extends TExplicitType
                ? WithConstructors<
                    TConstructorSchemas,
                    RespectPropsOptionality<TProperties>,
                >
                : TExplicitType
        :
            | (
                TNullable extends true
                    ? | (
                        undefined extends TExplicitType
                            ? WithConstructors<
                                TConstructorSchemas,
                                RespectPropsOptionality<TProperties>,
                            >
                            : TExplicitType
                    )
                    | null
                    : undefined extends TExplicitType
                        ? WithConstructors<
                            TConstructorSchemas,
                            RespectPropsOptionality<TProperties>,
                        >
                        : TExplicitType
            )
            | undefined

    Type-level brand encoding the inferred type of this schema. Not emitted at runtime — used only by InferType.

    "[SYMBOL_HAS_PROPERTIES]": true

    Marks this builder as having sub-properties for descriptor tree recursion.

    Accessors

    • get "~standard"(): StandardSchemaV1.Props<
          ResolvedSchemaType<TResult, TRequired, TNullable>,
      >

      Standard Schema v1 interface.

      Exposes this schema as a Standard Schema v1 validator, enabling out-of-the-box interoperability with any library that consumes the spec — including tRPC, TanStack Form, React Hook Form, T3 Env, Hono, Elysia, next-safe-action, and 50+ other tools.

      Every SchemaBuilder subclass (all 13 builders) inherits this property automatically — no additional setup required.

      Shape of the returned object:

      • version — always 1 (Standard Schema spec version)
      • vendor'@cleverbrush/schema'
      • validate(value) — synchronous; wraps this builder's own .validate() and converts its result to the Standard Schema Result<Output> format:
        • Success: { value: <validated output> }
        • Failure: { issues: [{ message: string }, …] }

      The returned object is cached after the first access so repeated reads return the same reference (required by the spec).

      Returns StandardSchemaV1.Props<ResolvedSchemaType<TResult, TRequired, TNullable>>

      import { object, string, number } from '@cleverbrush/schema';

      const UserSchema = object({
      name: string().minLength(2),
      email: string().email(),
      age: number().min(18).optional(),
      });

      // Grab the Standard Schema interface
      const std = UserSchema['~standard'];
      // std.version === 1
      // std.vendor === '@cleverbrush/schema'

      const ok = std.validate({ name: 'Alice', email: 'alice@example.com' });
      // { value: { name: 'Alice', email: 'alice@example.com', age: undefined } }

      const fail = std.validate({ name: 'A', email: 'not-an-email' });
      // { issues: [{ message: 'minLength' }, { message: 'email' }] }

      // Pass directly to TanStack Form, T3 Env, tRPC, etc.:
      // validators: { onChange: UserSchema, onBlur: UserSchema }
    • get canSkipPreValidation(): boolean

      Whether preValidateSync can be skipped entirely. True when there are no preprocessors and no validators, so the only work would be the required check and wrapping in a noop transaction — which subclasses can do inline.

      Returns boolean

    • get hasCatch(): boolean

      Whether this schema has a catch/fallback value configured via .catch().

      Returns boolean

    • get hasDefault(): boolean

      Whether this schema has a default value configured via .default(). Exposed for fast-path validation in subclasses.

      Returns boolean

    • get isNullable(): boolean

      Whether null is an accepted value for this schema.

      Returns boolean

    • get isNullRequiredViolation(): boolean
      Protected

      Whether null should count as a required-constraint violation.

      By default null is treated the same as undefined for the purposes of the required check — i.e. a required schema rejects both. Subclasses that may legally receive null as a value (e.g. UnionSchemaBuilder when a NullSchemaBuilder option is present) can override this to false so that null bypasses the required check and is passed directly to their option-validation logic.

      Returns boolean

    • get isReadonly(): boolean

      Whether this schema is marked as readonly. Type-level only — no runtime enforcement.

      Returns boolean

    • get isRequired(): TRequired

      Whether the schema requires a non-null/non-undefined value.

      Returns TRequired

    • set isRequired(value: boolean): void

      Sets the requirement flag. Must be a boolean.

      Parameters

      • value: boolean

      Returns void

    • get preprocessors(): PreprocessorEntry<TResult>[]

      A list of preprocessors associated with the Builder

      Returns PreprocessorEntry<TResult>[]

    • get type(): string

      The string identifier of the schema type (e.g. 'string', 'number', 'object').

      Returns string

    • set type(value: string): void

      Sets the schema type identifier. Must be a non-empty string.

      Parameters

      • value: string

      Returns void

    • get validators(): ValidatorEntry<TResult>[]

      A list of validators associated with the Builder

      Returns ValidatorEntry<TResult>[]

    Methods

    • Appends a constructor overload to the object schema.

      Each call extends the set of construct signatures on the inferred type by one overload. The accumulated argument lists are taken from the FunctionSchemaBuilder passed in — specifically from the positional parameter schemas registered via .addParameter().

      At runtime the schema continues to validate plain objects; the constructor information is purely a TypeScript-level annotation and is stored in introspect().constructorSchemas for tooling use.

      Multiple calls are supported and produce overloaded construct signatures in the inferred type, modelling a class that exposes several constructor overloads.

      Type Parameters

      Parameters

      • schema: TFunc

        A FunctionSchemaBuilder describing one constructor overload. Use .addParameter() on the function schema to declare the parameter types. The return type, if set via .hasReturnType(), is ignored — the return type of a constructor is always the instance type derived from the object schema's properties.

      Returns ObjectSchemaBuilder<
          TProperties,
          TRequired,
          TNullable,
          TExplicitType,
          THasDefault,
          TExtensions,
          [...TConstructorSchemas[], TFunc],
      > & TExtensions

      A new ObjectSchemaBuilder whose TConstructorSchemas tuple has been extended by schema, updating InferType to include the new construct signature.

      import { object, string, number, func, InferType } from '@cleverbrush/schema';

      // Single constructor
      const PersonSchema = object({ name: string(), age: number() })
      .addConstructor(
      func().addParameter(string()).addParameter(number())
      );

      type Person = InferType<typeof PersonSchema>;
      // → { new (p0: string, p1: number): { name: string; age: number } }
      // & { name: string; age: number }
      import { object, string, number, func, InferType } from '@cleverbrush/schema';

      // Multiple constructors via chained calls → overloaded signatures
      const PointSchema = object({ x: number(), y: number() })
      .addConstructor(func()) // no-arg ctor
      .addConstructor(func().addParameter(number()).addParameter(number())); // (x, y) ctor

      type Point = InferType<typeof PointSchema>;
      // → { new (): { x: number; y: number } }
      // & { new (p0: number, p1: number): { x: number; y: number } }
      // & { x: number; y: number }

      // Validation still operates on plain objects — the constructor type is
      // a compile-time annotation only.
      const result = PointSchema.validate({ x: 1, y: 2 });
      // result.valid === true

      // Introspect the registered constructor schemas at runtime:
      const info = PointSchema.introspect();
      // info.constructorSchemas.length === 2
    • Adds a preprocessor to a preprocessors list

      Parameters

      • preprocessor: Preprocessor<
            undefined extends TExplicitType
                ? WithConstructors<
                    TConstructorSchemas,
                    RespectPropsOptionality<TProperties>,
                >
                : TExplicitType,
        >
      • Optionaloptions: { mutates?: boolean }

      Returns this

    • Adds a validator to validators list.

      Object-level validators can return errors with a property selector to route the error to a specific property, making it visible via getErrorsFor().

      schema.addValidator((value) => ({
      valid: false,
      errors: [{
      message: 'Passwords do not match',
      property: (t) => t.confirmPassword
      }]
      }));

      The property selector uses the same PropertyDescriptorTree as getErrorsFor() and react-form's forProperty.

      Parameters

      • validator: (
            object: undefined extends TExplicitType
                ? WithConstructors<
                    TConstructorSchemas,
                    RespectPropsOptionality<TProperties>,
                >
                : TExplicitType,
        ) =>
            | {
                errors?: {
                    message: string;
                    property?: (
                        properties: PropertyDescriptorTree<
                            ObjectSchemaBuilder<
                                TProperties,
                                true,
                                false,
                                undefined,
                                false,
                                {},
                                [],
                            >,
                        >,
                    ) => PropertyDescriptor<any, any, any>;
                }[];
                valid: boolean;
            }
            | Promise<
                {
                    errors?: {
                        message: string;
                        property?: (
                            properties: PropertyDescriptorTree<
                                ObjectSchemaBuilder<
                                    (...),
                                    (...),
                                    (...),
                                    (...),
                                    (...),
                                    (...),
                                    (...),
                                >,
                            >,
                        ) => PropertyDescriptor<any, any, any>;
                    }[];
                    valid: boolean;
                },
            >
      • Optionaloptions: { mutates?: boolean }

      Returns this

    • Sets a fallback value for this schema. When validation fails for any reason, the fallback value is returned as a successful result instead of validation errors.

      This is useful for graceful degradation — for example, providing a safe default when parsing untrusted input that might not conform to the schema.

      Accepts either a static value or a factory function. Factory functions are called each time the fallback is needed (useful for mutable values like () => []).

      Unlike default, which only fires when the input is undefined, .catch() fires on any validation failure — type mismatch, constraint violation, etc.

      When .catch() is set, parse and parseAsync will never throw.

      Parameters

      • value:
            | (
                undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | (
                () => undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )

        the fallback value, or a factory function producing the fallback

      Returns this

      const schema = string().catch('unknown');
      schema.validate(42); // { valid: true, object: 'unknown' }
      schema.validate('hello'); // { valid: true, object: 'hello' }
      schema.parse(42); // 'unknown' (no throw)
      // Factory function for mutable fallbacks
      const schema = array(string()).catch(() => []);
      schema.validate(null); // { valid: true, object: [] }
      // Contrast with .default() — default fires only on undefined
      const d = string().default('anon');
      d.validate(undefined); // { valid: true, object: 'anon' } ← fires
      d.validate(42); // { valid: false, errors: [...] } ← does NOT fire

      const c = string().catch('anon');
      c.validate(undefined); // { valid: true, object: 'anon' } ← fires
      c.validate(42); // { valid: true, object: 'anon' } ← also fires
    • Removes all constructor overloads previously registered via .addConstructor(), resetting the TConstructorSchemas tuple to [].

      After calling this method InferType reverts to the plain object type derived from the schema's properties — no construct signatures are included.

      introspect().constructorSchemas will return an empty array.

      Returns ObjectSchemaBuilder<
          TProperties,
          TRequired,
          TNullable,
          TExplicitType,
          THasDefault,
          TExtensions,
          [],
      > & TExtensions

      A new ObjectSchemaBuilder with TConstructorSchemas = [].

      import { object, string, func, InferType } from '@cleverbrush/schema';

      const WithCtor = object({ name: string() })
      .addConstructor(func().addParameter(string()));

      type WithCtorType = InferType<typeof WithCtor>;
      // → { new (p0: string): { name: string } } & { name: string }

      const Plain = WithCtor.clearConstructors();

      type PlainType = InferType<typeof Plain>;
      // → { name: string }

      Plain.introspect().constructorSchemas; // []
    • Remove all preprocessors for this schema.

      Returns this

    • Remove all validators for this schema.

      Returns this

    • Protected method used to create a new instance of the Builder defined by the props object. Should be used to instantiate new builders to keep builder's immutability.

      Type Parameters

      • T extends Record<string, SchemaBuilder<any, true, false, false, {}>>
      • R extends boolean = true

      Parameters

      • props: ObjectSchemaBuilderCreateProps<T, R>

        arbitrary props object

      Returns this

    • Recursively marks all properties — and all properties of nested object() schemas — as optional. Useful for PATCH API bodies and partial form state where every field at every level is optional.

      Only nested ObjectSchemaBuilder schemas are recursed into. Other schema types (arrays, unions, primitives, lazy) are made optional at the top level but their internals are not modified.

      Returns ObjectSchemaBuilder<
          DeepMakeChildrenOptional<TProperties>,
          TRequired,
          TNullable,
          TExplicitType,
          THasDefault,
          TExtensions,
          TConstructorSchemas,
      > & TExtensions

      const Address = object({
      street: string(),
      city: string()
      });

      const User = object({
      name: string(),
      address: Address
      });

      const PatchUser = User.deepPartial();
      // PatchUser infers as:
      // { name?: string; address?: { street?: string; city?: string } }

      PatchUser.validate({ address: { city: 'Paris' } }); // valid
      PatchUser.validate({}); // valid
      // Three-level nesting
      const schema = object({
      a: object({
      b: object({ c: string() })
      })
      }).deepPartial();

      schema.validate({}); // valid
      schema.validate({ a: {} }); // valid
      schema.validate({ a: { b: {} } }); // valid
      // PATCH API body
      const CreateBody = object({
      profile: object({ displayName: string(), bio: string() }),
      settings: object({ theme: string(), language: string() })
      });

      const PatchBody = CreateBody.deepPartial();
      // All fields are optional at every level —
      // send only what you want to update.

      partial for shallow-only property optionality.

    • Attaches a human-readable description to this schema as runtime metadata.

      The description has no effect on validation — it is purely informational. It is accessible via .introspect().description and is emitted as the description field by toJsonSchema() from @cleverbrush/schema-json.

      Useful for documentation generation, form labels, and AI tool descriptions.

      Parameters

      • text: string

      Returns this

      const schema = object({
      name: string().describe('The user\'s full name'),
      age: number().optional().describe('Age in years'),
      }).describe('A user object');

      schema.introspect().description; // 'A user object'
    • Attaches an example value to this schema instance.

      The example is purely metadata — it has no effect on validation. It is accessible via .introspect().example and is emitted as the example keyword in JSON Schema output and OpenAPI spec generation.

      Parameters

      Returns this

      import { string } from '@cleverbrush/schema';

      const Email = string().example('user@example.com');

      Email.introspect().example; // 'user@example.com'
    • Internal

      Retrieves extension metadata by key. Used by extension authors inside defineExtension() callbacks.

      Parameters

      • key: string

      Returns unknown

    • Generates a serializable object describing the defined schema

      Returns {
          acceptUnknownProps: boolean;
          catchValue:
              | (
                  undefined extends TExplicitType
                      ? WithConstructors<
                          TConstructorSchemas,
                          RespectPropsOptionality<TProperties>,
                      >
                      : TExplicitType
              )
              | (
                  () => undefined extends TExplicitType
                      ? WithConstructors<
                          TConstructorSchemas,
                          RespectPropsOptionality<TProperties>,
                      >
                      : TExplicitType
              )
              | undefined;
          constructorSchemas: TConstructorSchemas;
          defaultValue:
              | (
                  undefined extends TExplicitType
                      ? WithConstructors<
                          TConstructorSchemas,
                          RespectPropsOptionality<TProperties>,
                      >
                      : TExplicitType
              )
              | (
                  () => undefined extends TExplicitType
                      ? WithConstructors<
                          TConstructorSchemas,
                          RespectPropsOptionality<TProperties>,
                      >
                      : TExplicitType
              )
              | undefined;
          description: string | undefined;
          example: unknown;
          extensions: { [key: string]: unknown };
          hasCatch: boolean;
          hasDefault: boolean;
          isNullable: boolean;
          isReadonly: boolean;
          isRequired: boolean;
          preprocessors: readonly PreprocessorEntry<
              undefined extends TExplicitType
                  ? WithConstructors<
                      TConstructorSchemas,
                      RespectPropsOptionality<TProperties>,
                  >
                  : TExplicitType,
          >[];
          properties: TProperties;
          requiredValidationErrorMessageProvider: ValidationErrorMessageProvider<
              SchemaBuilder<any, any, any, any, any>,
          >;
          schemaName: string | undefined;
          type: string;
          validators: readonly ValidatorEntry<
              undefined extends TExplicitType
                  ? WithConstructors<
                      TConstructorSchemas,
                      RespectPropsOptionality<TProperties>,
                  >
                  : TExplicitType,
          >[];
      }

      • acceptUnknownProps: boolean

        If set to true, schema validation will not return errors if object contains fields which are not defined in the schema properties. Set to false by default

      • catchValue:
            | (
                undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | (
                () => undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | undefined

        The catch/fallback value or factory function set via .catch().

      • constructorSchemas: TConstructorSchemas

        The list of constructor schemas registered via .addConstructor(). Each element is a FunctionSchemaBuilder whose inferred function type provides one overloaded construct signature in InferType. Empty array when no constructors have been added.

      • defaultValue:
            | (
                undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | (
                () => undefined extends TExplicitType
                    ? WithConstructors<
                        TConstructorSchemas,
                        RespectPropsOptionality<TProperties>,
                    >
                    : TExplicitType
            )
            | undefined

        The default value or factory function.

      • description: string | undefined

        The human-readable description attached to this schema via .describe(), or undefined if none was set.

      • example: unknown

        An example value attached to this schema via .example(), or undefined if none was set.

      • extensions: { [key: string]: unknown }

        Extension metadata. Stores custom state set by schema extensions.

      • hasCatch: boolean

        Whether a catch/fallback value has been set on this schema via .catch().

      • hasDefault: boolean

        Whether a default value (or factory) has been set on this schema.

      • isNullable: boolean

        If set to true, schema values of null are considered valid.

      • isReadonly: boolean

        If set to true, the inferred type is marked as readonly. Type-level only — no runtime enforcement.

      • isRequired: boolean

        If set to false, schema will be optional (null or undefined values will be considered as valid).

      • preprocessors: readonly PreprocessorEntry<
            undefined extends TExplicitType
                ? WithConstructors<
                    TConstructorSchemas,
                    RespectPropsOptionality<TProperties>,
                >
                : TExplicitType,
        >[]

        Array of preprocessor functions

      • properties: TProperties

        Properties defined in schema

      • requiredValidationErrorMessageProvider: ValidationErrorMessageProvider<SchemaBuilder<any, any, any, any, any>>

        Custom error message provider for the 'is required' validation error.

      • schemaName: string | undefined

        The logical name attached to this schema via .schemaName(), or undefined if none was set.

      • type: string

        String id of schema type, e.g. string', numberorobject`.

      • validators: readonly ValidatorEntry<
            undefined extends TExplicitType
                ? WithConstructors<
                    TConstructorSchemas,
                    RespectPropsOptionality<TProperties>,
                >
                : TExplicitType,
        >[]

        Array of validator functions

    • Synchronously validates the value and returns it if valid. Throws a SchemaValidationError if validation fails.

      Parameters

      • object: any

        the value to parse

      • Optionalcontext: ValidationContext<SchemaBuilder<any, any, any, any, {}>>

        optional validation context

      Returns undefined extends TExplicitType
          ? WithConstructors<
              TConstructorSchemas,
              RespectPropsOptionality<TProperties>,
          >
          : TExplicitType

      the validated value

      SchemaValidationError if validation fails

      Error if the schema contains async preprocessors, validators, or error message providers

    • Asynchronously validates the value and returns it if valid. Throws a SchemaValidationError if validation fails.

      Parameters

      • object: any

        the value to parse

      • Optionalcontext: ValidationContext<SchemaBuilder<any, any, any, any, {}>>

        optional validation context

      Returns Promise<
          undefined extends TExplicitType
              ? WithConstructors<
                  TConstructorSchemas,
                  RespectPropsOptionality<TProperties>,
              >
              : TExplicitType,
      >

      the validated value

      SchemaValidationError if validation fails

    • Parameters

      • object: any
      • Optionalcontext: ValidationContext<SchemaBuilder<any, any, any, any, {}>>

      Returns Promise<PreValidationResult<any, { validatedObject: any }>>

      Use preValidateAsync instead. This alias will be removed in a future version.

    • Async version of pre-validation. Runs preprocessors, validators, and the required/optional check on object. Supports async preprocessors, validators, and error message providers.

      Parameters

      Returns Promise<
          PreValidationResult<
              TRequired extends true
                  ? undefined extends TExplicitType
                      ? Id<RespectPropsOptionality<TProperties>>
                      : TExplicitType
                  :
                      | (
                          undefined extends TExplicitType
                              ? Id<RespectPropsOptionality<TProperties>>
                              : TExplicitType
                      )
                      | undefined,
              { validatedObject: any },
          >,
      >

      a PreValidationResult containing the preprocessed transaction, context, and any errors

    • Synchronous version of preValidateAsync. Throws at runtime if any preprocessor or validator returns a Promise.

      Parameters

      Returns PreValidationResult<
          TRequired extends true
              ? undefined extends TExplicitType
                  ? Id<RespectPropsOptionality<TProperties>>
                  : TExplicitType
              :
                  | (
                      undefined extends TExplicitType
                          ? Id<RespectPropsOptionality<TProperties>>
                          : TExplicitType
                  )
                  | undefined,
          { validatedObject: any },
      >

      a PreValidationResult containing the preprocessed transaction, context, and any errors

      Error if a preprocessor or validator returns a Promise (use preValidateAsync instead)

    • Alias for validateAsync. Asynchronously validates and returns a result object. Provided for familiarity with the zod API.

      Parameters

      • object: any
      • Optionalcontext: ValidationContext<SchemaBuilder<any, any, any, any, {}>>

      Returns Promise<
          ValidationResult<
              undefined extends TExplicitType
                  ? WithConstructors<
                      TConstructorSchemas,
                      RespectPropsOptionality<TProperties>,
                  >
                  : TExplicitType,
          >,
      >

    • Attaches a logical name to this schema instance.

      The name is purely metadata — it has no effect on validation. It is accessible via .introspect().schemaName and can be consumed by any tool that introspects schemas at runtime, such as OpenAPI spec generators, documentation tools, form libraries, or code generators.

      Uniqueness is the responsibility of the consuming tool. Passing the same constant (same object reference) to multiple consumers is always safe; how conflicts between different instances with the same name are handled depends on the tool.

      Parameters

      • name: string

      Returns this

      import { object, string, number } from '@cleverbrush/schema';

      export const UserSchema = object({
      id: number(),
      name: string(),
      }).schemaName('User');

      UserSchema.introspect().schemaName; // 'User'
    • Internal

      Sets extension metadata by key. Returns a new schema instance with the extension data stored. The data survives fluent chaining. Used by extension authors inside defineExtension() callbacks.

      Parameters

      • key: string
      • value: unknown

      Returns this

    • Parameters

      Returns boolean