diff --git a/package.json b/package.json index 5f9d50a2..1a334076 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "skyflow-js", "preferGlobal": true, "analyze": false, - "version": "2.7.3", + "version": "2.7.3-dev.3a4806e", "author": "Skyflow", "description": "Skyflow JavaScript SDK", "homepage": "https://github.com/skyflowapi/skyflow-js", diff --git a/samples/using-typescript/collect-element-listeners/src/index.ts b/samples/using-typescript/collect-element-listeners/src/index.ts index ebf27c1e..f3a9e015 100644 --- a/samples/using-typescript/collect-element-listeners/src/index.ts +++ b/samples/using-typescript/collect-element-listeners/src/index.ts @@ -53,6 +53,9 @@ try { borderRadius: '4px', color: '#1d1d1d', marginTop: '4px', + "&:hover": { +      borderColor: "green", +    }, }, complete: { color: '#4caf50', diff --git a/samples/using-typescript/composable-elements/src/index.ts b/samples/using-typescript/composable-elements/src/index.ts index 9a81f01f..5eea46fe 100644 --- a/samples/using-typescript/composable-elements/src/index.ts +++ b/samples/using-typescript/composable-elements/src/index.ts @@ -57,7 +57,10 @@ try { fontWeight: '400', fontSize: '14px', lineHeight: '21px', - width: '294px' + width: '294px', + "&:hover": { +      borderColor: "green", +     }, }, global: { '@import' :'url("https://fonts.googleapis.com/css2?family=Roboto&display=swap")', diff --git a/src/utils/common/index.ts b/src/utils/common/index.ts index 26baa018..ecf72435 100644 --- a/src/utils/common/index.ts +++ b/src/utils/common/index.ts @@ -291,6 +291,8 @@ export interface DeleteErrorRecords { error: ErrorRecord, } +export type Style = string | { [key: string]: Style }; + export interface ContainerOptions { layout: number[], styles?: InputStyles, // check implementation below @@ -298,22 +300,22 @@ export interface ContainerOptions { } export interface ErrorTextStyles { - base?: Record, - global?: Record, + base?: Record, + global?: Record, } export interface LabelStyles extends ErrorTextStyles { - focus?: Record, - requiredAsterisk?: Record, + focus?: Record, + requiredAsterisk?: Record, } export interface InputStyles extends ErrorTextStyles { - focus?: Record, - complete?: Record, - empty?: Record, - invalid?: Record, - cardIcon?: Record, - copyIcon?: Record, + focus?: Record, + complete?: Record, + empty?: Record, + invalid?: Record, + cardIcon?: Record, + copyIcon?: Record, } export interface CollectElementOptions { diff --git a/src/utils/validators/index.ts b/src/utils/validators/index.ts index f4ce7a88..48f681cd 100644 --- a/src/utils/validators/index.ts +++ b/src/utils/validators/index.ts @@ -78,6 +78,8 @@ export const validateExpiryDate = (date: string, format: string) => { if (!date.includes('/')) return false; const { month, year } = getYearAndMonthBasedOnFormat(date, format); if (format.endsWith('YYYY') && year.toString().length !== 4) { return false; } + const monthNum = Number(month); + if (monthNum < 1 || monthNum > 12) { return false; } const expiryDate = new Date(Number(year), Number(month), 0); expiryDate.setHours(23, 59, 59, 999); const today = new Date(); @@ -85,7 +87,6 @@ export const validateExpiryDate = (date: string, format: string) => { const maxDate = new Date(); maxDate.setFullYear(today.getFullYear() + 50); maxDate.setMonth(today.getMonth() + 1); - return expiryDate >= today && expiryDate <= maxDate; }; diff --git a/tests/utils/validators.test.js b/tests/utils/validators.test.js index c67b5b7e..c1ef6763 100644 --- a/tests/utils/validators.test.js +++ b/tests/utils/validators.test.js @@ -66,6 +66,56 @@ describe('Validation card number and Expiry Date', () => { expect(validateExpiryDate(expiryDate, "MM/YY")).toBe(false); }); + test('validate expiry date with month 00, MM/YY', () => { + const expiryDate = '00/45'; + expect(validateExpiryDate(expiryDate, "MM/YY")).toBe(false); + }); + + test('validate expiry date with month 13, MM/YY', () => { + const expiryDate = '13/45'; + expect(validateExpiryDate(expiryDate, "MM/YY")).toBe(false); + }); + + test('validate expiry date with month 00, YY/MM', () => { + const expiryDate = '45/00'; + expect(validateExpiryDate(expiryDate, "YY/MM")).toBe(false); + }); + + test('validate expiry date with month 13, YY/MM', () => { + const expiryDate = '45/13'; + expect(validateExpiryDate(expiryDate, "YY/MM")).toBe(false); + }); + + test('validate expiry date with month 00, YYYY/MM', () => { + const expiryDate = '2045/00'; + expect(validateExpiryDate(expiryDate, "YYYY/MM")).toBe(false); + }); + + test('validate expiry date with month 13, YYYY/MM', () => { + const expiryDate = '2045/13'; + expect(validateExpiryDate(expiryDate, "YYYY/MM")).toBe(false); + }); + + test('validate older expiry date with month 00, YYYY/MM', () => { + const expiryDate = '2024/00'; + expect(validateExpiryDate(expiryDate, "YYYY/MM")).toBe(false); + }); + + test('validate older expiry date with month 13, YYYY/MM', () => { + const expiryDate = '2024/13'; + expect(validateExpiryDate(expiryDate, "YYYY/MM")).toBe(false); + }); + + test('validate expiry date with month 00, MM/YYYY', () => { + const expiryDate = '00/2045'; + expect(validateExpiryDate(expiryDate, "MM/YYYY")).toBe(false); + }); + + test('validate expiry date with month 13, MM/YYYY', () => { + const expiryDate = '13/2045'; + expect(validateExpiryDate(expiryDate, "MM/YYYY")).toBe(false); + }); + test('validate expired date, MM/YY', () => { const currentDate = new Date(); const expiryDate = `${currentDate.getMonth()}/${currentDate.getFullYear().toString().slice(-2)}`;