typebox-schema-faker
Version:
Generate fake data from TypeBox schemas for testing, prototyping and development.
18 lines (17 loc) • 639 B
TypeScript
import type { Static, TSchema } from '@sinclair/typebox';
import type { FakerOptions } from './types';
/**
* Generates fake data matching the provided TypeBox schema
*
* @template T — The TypeBox schema type
* @param schema — The TypeBox schema to generate fake data for
* @returns Fake data matching the schema's static type
* @throws {TypeBoxError} When the schema type is not supported
*
* @example
* ```ts
* const nameSchema = Type.String({ minLength: 3, maxLength: 10 });
* fake(nameSchema); // "a7B9x2"
* ```
*/
export declare function fake<T extends TSchema>(schema: T, options?: Partial<FakerOptions>): Static<T>;