createAssetValidator

See source code

Create 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
        | 'id'
        | 'meta'
        | 'typeName'
        | (undefined extends Props ? never : 'props')
        | (undefined extends Type ? never : 'type')]: {
        id: TLAssetId
        meta: JsonObject
        props: Props
        type: Type
        typeName: 'asset'
      }[P]
    } & {
      [P_1 in
        | (undefined extends Props ? 'props' : never)
        | (undefined extends Type ? 'type' : never)]?:
        | {
            id: TLAssetId
            meta: JsonObject
            props: Props
            type: Type
            typeName: 'asset'
          }[P_1]
        | undefined
    }
  >
>

Parameters

NameDescription

type

Type

The type of the asset

props

T.Validator<Props>

The validator for the asset's props

Returns

T.ObjectValidator<
  import('@tldraw/utils').Expand<
    {
      [P in
        | 'id'
        | 'meta'
        | 'typeName'
        | (undefined extends Props ? never : 'props')
        | (undefined extends Type ? never : 'type')]: {
        id: TLAssetId
        meta: JsonObject
        props: Props
        type: Type
        typeName: 'asset'
      }[P]
    } & {
      [P_1 in
        | (undefined extends Props ? 'props' : never)
        | (undefined extends Type ? 'type' : never)]?:
        | {
            id: TLAssetId
            meta: JsonObject
            props: Props
            type: Type
            typeName: 'asset'
          }[P_1]
        | undefined
    }
  >
>
Prev
useUiEvents
Next
createBindingId