core.isreference | Medplum

isReference() function

Type guard to validate that an object is a FHIR reference

Signature:

export declare function isReference<T extends Resource = Resource>(value: unknown, resourceType?: T['resourceType']): value is Reference<T> & {
    reference: string;
};

Parameters

Parameter Type Description
value unknown The object to check
resourceType T['resourceType'] (Optional) Checks that the reference is of the given type

Returns:

value is Reference & { reference: string; }

True if the input is of type 'object' and contains property 'reference'