Skip to main content

Function: isBlobRef()

isBlobRef(value): value is BlobRef

Defined in: src/types/atproto-validators.ts:215

Type guard for BlobRef objects.

Parameters

value

unknown

Value to check

Returns

value is BlobRef

True if value is a valid BlobRef

Remarks

Validates that an unknown value conforms to the BlobRef interface:

  • Has $type property equal to 'blob'
  • Has ref property (CID)
  • Has mimeType property (string)
  • Has size property (number)

This guard performs structural validation but does not validate the CID format or MIME type validity.

Example

const blob = {
$type: 'blob' as const,
ref: 'bafyreib...' as CID,
mimeType: 'application/pdf',
size: 2048576
};

if (isBlobRef(blob)) {
console.log('Valid BlobRef:', blob.ref);
}