twenty / packages /twenty-shared /src /utils /validation /assertIsDefinedOrThrow.ts
Jules
Initial clean CRM deployment with prebuilt assets
d9494a5
Raw
History Blame Contribute Delete
367 Bytes
import { isDefined } from '@/utils';
// https://github.com/microsoft/TypeScript/issues/34523
// oxlint-disable-next-line prefer-arrow/prefer-arrow-functions
export function assertIsDefinedOrThrow<T>(
value: T | undefined | null,
exceptionToThrow: Error = new Error('Value not defined'),
): asserts value is T {
if (!isDefined(value)) throw exceptionToThrow;
}