UNPKG

unhoax-chance

Version:

Generate seeded Chance fixtures based on unhoax schemas

31 lines (30 loc) 944 B
import type { GenerateFixtureFromSchema } from './internal/GenerateFixtureFromSchema'; /** * Mutate this object to override a built-in factory or add new ones * * @category Customizing * @example Adding factories for custom types * ```ts * type Email = string & { _tag: 'email' } * declare const isEmail: (input: unknown) => input is Email * * const emailSchema = x.fromGuard( * 'Email', // This name will be used for factories. * isEmail, * ) * * // registering your factory: * import { factories } from 'unhoax-chance' * * factories.Email = (chance) => chance.email() as Email * ``` * <br> * <br> * @example Overriding a built-in factory Danger Zone ⚠️ Constraints won’t be handled by default. * ```ts * import { factories } from 'unhoax-chance' * * factories.boolean = (chance) => chance.bool({ likelihood: 0.75 }) * ``` */ export declare const factories: Record<string, GenerateFixtureFromSchema<any>>;