diff --git a/types/card-validator/card-validator-tests.ts b/types/card-validator/card-validator-tests.ts index 79ceda9b38..1b83ee8ecf 100644 --- a/types/card-validator/card-validator-tests.ts +++ b/types/card-validator/card-validator-tests.ts @@ -1,31 +1,27 @@ import valid = require('card-validator'); -var numberValidation = valid.number('4111'); +const numberValidation = valid.number('4111'); -if (!numberValidation.isPotentiallyValid) { - -} -if (numberValidation.card) { +if (!numberValidation.isPotentiallyValid && numberValidation.card) { numberValidation.card.type; } valid.expirationDate('10/19'); -let dateTest2 = valid.expirationDate({month: '1', year: '2019'}) +const dateTest2 = valid.expirationDate({month: '1', year: '2019'}); if (dateTest2.isPotentiallyValid) { dateTest2.month; } -let expirationMonthCheck = valid.expirationMonth('10'); +const expirationMonthCheck = valid.expirationMonth('10'); if (expirationMonthCheck.isPotentiallyValid) { - expirationMonthCheck.isValidForThisYear + expirationMonthCheck.isValidForThisYear; } -let expirationYearCheck = valid.expirationYear('10'); +const expirationYearCheck = valid.expirationYear('10'); if (expirationYearCheck.isPotentiallyValid) { expirationYearCheck.isCurrentYear; } - let postalCodeCheck = valid.postalCode('123'); if (postalCodeCheck.isValid) { @@ -33,7 +29,7 @@ if (postalCodeCheck.isValid) { postalCodeCheck = valid.postalCode('123', {minLength: 5}); } -let cvvCeck = valid.cvv('1234'); +const cvvCeck = valid.cvv('1234'); if (cvvCeck.isValid) { - valid.cvv('12345', 4) + valid.cvv('12345', 4); } diff --git a/types/card-validator/index.d.ts b/types/card-validator/index.d.ts index 458583588b..2412e7ebd3 100644 --- a/types/card-validator/index.d.ts +++ b/types/card-validator/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for card-validator +// Type definitions for card-validator 4.1.0 // Project: https://github.com/braintree/card-validator // Definitions by: Gregory Moore // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,7 +10,7 @@ interface Card { isAmex: boolean; gaps: number[]; lengths: number[]; - code: {name: string, size: number} + code: {name: string, size: number}; } interface valid { @@ -35,10 +35,9 @@ interface validExpirationYear extends valid { isCurrentYear: boolean; } - -export declare function number(value: string): validNumber; -export declare function expirationDate(value: string | {month: string, year: string}): validExpirationDate; -export declare function expirationMonth(value: string): validExpirationMonth; -export declare function expirationYear(value: string): validExpirationYear; -export declare function cvv(value: string, maxLength?: number): valid; -export declare function postalCode(value: string, options?: {minLength?: number}): valid; +export function number(value: string): validNumber; +export function expirationDate(value: string | {month: string, year: string}): validExpirationDate; +export function expirationMonth(value: string): validExpirationMonth; +export function expirationYear(value: string): validExpirationYear; +export function cvv(value: string, maxLength?: number): valid; +export function postalCode(value: string, options?: {minLength?: number}): valid;