createAssetValidator
See source codeCreate a validator for an asset record type.
function createAssetValidator<Type extends string, Props extends JsonObject>(
type: Type,
props: T.Validator<Props>
): T.ObjectValidator<
import('@tldraw/utils').Expand<
{
[P in T.ExtractRequiredKeys<{
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}>]: {
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}[P]
} & {
[P_1 in T.ExtractOptionalKeys<{
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}>]?:
| {
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}[P_1]
| undefined
}
>
>
Parameters
Name | Description |
---|---|
|
The type of the asset |
|
The validator for the asset's props |
Returns
T.ObjectValidator<
import('@tldraw/utils').Expand<
{
[P in T.ExtractRequiredKeys<{
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}>]: {
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}[P]
} & {
[P_1 in T.ExtractOptionalKeys<{
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}>]?:
| {
id: TLAssetId
meta: JsonObject
props: Props
type: Type
typeName: 'asset'
}[P_1]
| undefined
}
>
>
Prev
useUiEventsNext
createBindingId