Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

335 B
Raw Blame
export const MAX_CHECKOUT_QUANTITY = 10000;

export const parseCheckoutQuantity = (quantity: unknown): number | null => {
	if (quantity === undefined || quantity === null) return 1;
	return typeof quantity === "number" &&
		Number.isInteger(quantity) &&
		quantity >= 1 &&
		quantity <= MAX_CHECKOUT_QUANTITY
		? quantity
		: null;
};