The value to validate
Type predicate indicating if the value is a valid QuantityObject
const qty = parseQuantity('100g');
if (isQuantityObject(qty)) {
console.log(`${qty.quantity}${qty.uom}`);
}
export function isQuantityObject(value: unknown): value is QuantityObject {
return quantityObjectSchema.safeParse(value).success;
}
Type guard to validate if a value is a valid QuantityObject. Checks for the presence and correct types of quantity (number) and uom (string).