UNPKG

object-shape-tester

Version:
60 lines (59 loc) 1.92 kB
import { type TNull, type TObject, type TOptional, type TSchema, type TUndefined, type TUnion } from '@sinclair/typebox'; /** * Checks if a schema is an object schema. * * @category Internal */ export declare function isObjectSchema(schema: TSchema): schema is TObject; /** * Checks if a schema is a union schema. * * @category Internal */ export declare function isUnionSchema(schema: TSchema): schema is TUnion; /** * Checks if a schema is an optional schema. * * @category Internal */ export declare function isOptionalSchema(schema: TSchema): schema is TOptional<TSchema>; /** * Checks if a schema is a null schema. * * @category Internal */ export declare function isNullSchema(schema: TSchema): schema is TNull; /** * Checks if a schema is an undefined schema. * * @category Internal */ export declare function isUndefinedSchema(schema: TSchema): schema is TUndefined; /** * Checks if a schema guard matches the schema or a part of the schema's union. * * @category Internal */ export declare function matchesSchemaGuard<T extends TSchema>(schema: TSchema, guard: (schema: TSchema) => schema is T): schema is T; /** * Checks if a schema can be nullable (optional, `undefined`, or `null`). * * @category Internal */ export declare function canSchemaBeNullable(schema: TSchema): boolean; /** * Inserts a value into a union schema, converting the original schema into a union if it isn't * already. * * @category Internal */ export declare function insertUnion({ insertion, originalSchema, }: { originalSchema: TSchema; insertion: TSchema; }): TUnion; /** * Runs a `transform` function on a schema or any part of its union that matches `guard`. * * @category Internal */ export declare function operateOnExtraction<const Guarded extends TSchema>(originalSchema: TSchema, guard: (schema: TSchema) => schema is Guarded, transform: (schema: Guarded) => TSchema): TSchema;