Skip to content

ChainGraph API Documentation / @badaitech/chaingraph-types / createObjectPortConfig

Function: createObjectPortConfig()

createObjectPortConfig<S>(config): ObjectPortConfig<S>

Defined in: packages/chaingraph-types/src/port/instances/ObjectPort.ts:396

Helper to create an ObjectPortConfig with proper type inference.

Use this function when constructing a configuration object so that the generic parameter for the ObjectSchema is inferred from the "schema" property.

Example: const config = createObjectPortConfig({ type: 'object', schema: createObjectSchema({ name: { type: 'string', minLength: 2 }, age: { type: 'number', min: 21 } }), defaultValue: { type: 'object', value: { name: { type: 'string', value: 'Alice' }, age: { type: 'number', value: 30 } } } })

Type Parameters

S

S extends IObjectSchema<Record<string, IPortConfig>>

Parameters

config

ObjectPortConfig<S>

The object port configuration.

Returns

ObjectPortConfig<S>

The same configuration with its generic parameter inferred.

Licensed under BUSL-1.1