function validateChoice()

in client/components/mma/upgrade/UpgradeSupportAmountForm.tsx [35:54]


function validateChoice(
	currentAmount: number,
	chosenAmount: number | null,
	minAmount: number,
	maxAmount: number,
	isOtherAmountSelected: boolean,
): string | null {
	if (!chosenAmount && !isOtherAmountSelected) {
		return 'Please make a selection';
	} else if (chosenAmount === currentAmount) {
		return 'This is the same amount as your current support. Please enter a new amount.';
	} else if (
		!chosenAmount ||
		chosenAmount < minAmount ||
		chosenAmount > maxAmount
	) {
		return `Enter a number between ${minAmount} and ${maxAmount}.`;
	}
	return null;
}