@lmapp/react-native-cloudpayments
Version:
π ΠΠΎΡΠ½ΡΠΉ SDK Π΄Π»Ρ ΠΈΠ½ΡΠ΅Π³ΡΠ°ΡΠΈΠΈ ΠΏΠ»Π°ΡΠ΅ΠΆΠ΅ΠΉ CloudPayments Π² React Native. ΠΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠ° Apple Pay, Google Pay, Π‘ΠΠ, Π±Π°Π½ΠΊΠΎΠ²ΡΠΊΠΈΡ ΠΊΠ°ΡΡ. ΠΠΎΠ»Π½Π°Ρ ΡΠΈΠΏΠΈΠ·Π°ΡΠΈΡ TypeScript. iOS 12+ ΠΈ Android 21+
15 lines (14 loc) β’ 637 B
JavaScript
;
export const isValidExpDate = expDate => {
if (typeof expDate !== 'string' || expDate.length !== 5) return false;
const [monthStr, yearStr] = expDate.split('/');
if (!monthStr || !yearStr) return false;
const month = parseInt(monthStr, 10);
const year = parseInt(yearStr, 10);
if (isNaN(month) || isNaN(year) || month < 1 || month > 12) return false;
const currentDate = new Date();
const currentYear = currentDate.getFullYear() % 100;
const currentMonth = currentDate.getMonth() + 1;
return year > currentYear || year === currentYear && month >= currentMonth;
};
//# sourceMappingURL=validation.js.map