Public function

Create a validator for an asset record type.

Signature
function createAssetValidator<Type extends string, Props extends JsonObject>(
  type: Type,
  props: T.Validator<Props>
): T.ObjectValidator<
  {
    [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<
  {
    [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
  }
>
References

T.Validator, T.ObjectValidator, TLAssetId

Source

packages/tlschema/src/assets/TLBaseAsset.ts

canvasUiColorTypeValidatorcreateBindingId