Skip to content

createBuildContext ​

Creates a build context for testing a field type's schema() on its own, without a definition around it.

ts
const ctx = createBuildContext(overrides)

Parameters ​

  • overrides Partial<BuildContext>: optional, replaces any member, like path

Explanation ​

Its buildFields and buildField use the default registries, and throw a DefinitionError when the child fields have issues. Its path defaults to [].

Returns ​

Example ​

ts
const field: JsonField = { name: 'tags', type: 'tags', max: 3 }
const schema = tags.schema?.(
  { ...field, max: 3 },
  createBuildContext({ path: ['fields', 0] }),
)

Guides ​

Types ​