typebox-schema-faker
Version:
Generate fake data from TypeBox schemas for testing, prototyping and development.
12 lines (11 loc) • 313 B
JavaScript
import { rootFake } from '../root';
import { unwrap } from '../unwrap';
/**
* Generates fake data for optional schemas
*/
export const fakeOptional = (schema, ctx, options) => {
if (ctx.faker.datatype.boolean(options)) {
return undefined;
}
return rootFake(unwrap(schema), ctx, options);
};