diff --git a/projects/addon-commerce/components/card/card.component.ts b/projects/addon-commerce/components/card/card.component.ts index b439cd3f5492..24bd222b002b 100644 --- a/projects/addon-commerce/components/card/card.component.ts +++ b/projects/addon-commerce/components/card/card.component.ts @@ -1,5 +1,5 @@ import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/core'; -import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types'; +import {TuiPaymentSystem, TuiPaymentSystemT} from '@taiga-ui/addon-commerce/enums'; import {tuiDefaultProp} from '@taiga-ui/cdk'; import {TuiSizeS} from '@taiga-ui/core'; @@ -10,12 +10,12 @@ export function cardNumberAssertion({length}: string): boolean { export const cardNumberAssertionMessage = 'cardNumber should contain 4 symbols'; -const icons: Record = { - mir: 'tuiIconMirMono', - visa: 'tuiIconVisaMono', - electron: 'tuiIconElectronMono', - mastercard: 'tuiIconMastercard', - maestro: 'tuiIconMaestro', +const icons = { + [TuiPaymentSystem.Mir]: 'tuiIconMirMono', + [TuiPaymentSystem.Visa]: 'tuiIconVisaMono', + [TuiPaymentSystem.Electron]: 'tuiIconElectronMono', + [TuiPaymentSystem.Mastercard]: 'tuiIconMastercard', + [TuiPaymentSystem.Maestro]: 'tuiIconMaestro', }; @Component({ @@ -40,7 +40,7 @@ export class TuiCardComponent { @Input() @tuiDefaultProp() - paymentSystem: TuiPaymentSystem | null = null; + paymentSystem: TuiPaymentSystem | TuiPaymentSystemT | null = null; @Input() @HostBinding('attr.data-size') diff --git a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts index 4cde736d73ab..ec9444c7e577 100644 --- a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts +++ b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts @@ -17,8 +17,9 @@ import { } from '@angular/core'; import {NgControl} from '@angular/forms'; import {TUI_CARD_MASK, tuiDefaultCardValidator} from '@taiga-ui/addon-commerce/constants'; +import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums'; import {TuiCard} from '@taiga-ui/addon-commerce/interfaces'; -import {TuiCodeCVCLength, TuiPaymentSystem} from '@taiga-ui/addon-commerce/types'; +import {TuiCodeCVCLength} from '@taiga-ui/addon-commerce/types'; import { tuiCreateAutoCorrectedExpirePipe, tuiGetPaymentSystem, @@ -63,12 +64,12 @@ const STUB: TuiCard = { expire: '', cvc: '', }; -const ICONS: Record = { - mir: 'tuiIconMir', - visa: 'tuiIconVisa', - electron: 'tuiIconElectron', - mastercard: 'tuiIconMastercard', - maestro: 'tuiIconMaestro', +const ICONS = { + [TuiPaymentSystem.Mir]: 'tuiIconMir', + [TuiPaymentSystem.Visa]: 'tuiIconVisa', + [TuiPaymentSystem.Electron]: 'tuiIconElectron', + [TuiPaymentSystem.Mastercard]: 'tuiIconMastercard', + [TuiPaymentSystem.Maestro]: 'tuiIconMaestro', }; // @dynamic diff --git a/projects/addon-commerce/components/input-card/input-card.component.ts b/projects/addon-commerce/components/input-card/input-card.component.ts index 1362ac8371cb..15cfcc1222ce 100644 --- a/projects/addon-commerce/components/input-card/input-card.component.ts +++ b/projects/addon-commerce/components/input-card/input-card.component.ts @@ -13,7 +13,7 @@ import { } from '@angular/core'; import {NgControl} from '@angular/forms'; import {TUI_CARD_MASK} from '@taiga-ui/addon-commerce/constants'; -import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types'; +import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums'; import {tuiGetPaymentSystem} from '@taiga-ui/addon-commerce/utils'; import { AbstractTuiControl, @@ -29,12 +29,12 @@ import { } from '@taiga-ui/core'; import {TextMaskConfig} from 'angular2-text-mask'; -const icons: Record = { - mir: 'tuiIconMir', - visa: 'tuiIconVisa', - electron: 'tuiIconElectron', - mastercard: 'tuiIconMastercard', - maestro: 'tuiIconMaestro', +const icons = { + [TuiPaymentSystem.Mir]: 'tuiIconMir', + [TuiPaymentSystem.Visa]: 'tuiIconVisa', + [TuiPaymentSystem.Electron]: 'tuiIconElectron', + [TuiPaymentSystem.Mastercard]: 'tuiIconMastercard', + [TuiPaymentSystem.Maestro]: 'tuiIconMaestro', }; // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/projects/addon-commerce/components/input-card/test/input-card.component.spec.ts b/projects/addon-commerce/components/input-card/test/input-card.component.spec.ts index bf0321a43fa2..e6eadbe6c8b1 100644 --- a/projects/addon-commerce/components/input-card/test/input-card.component.spec.ts +++ b/projects/addon-commerce/components/input-card/test/input-card.component.spec.ts @@ -3,6 +3,7 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, ReactiveFormsModule} from '@angular/forms'; import {configureTestSuite} from '@taiga-ui/testing'; +import {TuiPaymentSystem} from '../../../enums/payment-system'; import {TuiInputCardComponent} from '../input-card.component'; import {TuiInputCardModule} from '../input-card.module'; @@ -82,31 +83,33 @@ describe('InputCard', () => { it('visa', () => { testComponent.control.setValue('4111 1111 1111 1111'); - expect(testComponent.component.paymentSystem).toBe('visa'); + expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Visa); }); it('electron', () => { testComponent.control.setValue('4917300800000000'); - expect(testComponent.component.paymentSystem).toBe('electron'); + expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Electron); }); it('mir', () => { testComponent.control.setValue('2200654321000000'); - expect(testComponent.component.paymentSystem).toBe('mir'); + expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Mir); }); it('mastercard', () => { testComponent.control.setValue('5500 0000 0000 0004'); - expect(testComponent.component.paymentSystem).toBe('mastercard'); + expect(testComponent.component.paymentSystem).toBe( + TuiPaymentSystem.Mastercard, + ); }); it('maestro', () => { testComponent.control.setValue('6759649826438453'); - expect(testComponent.component.paymentSystem).toBe('maestro'); + expect(testComponent.component.paymentSystem).toBe(TuiPaymentSystem.Maestro); }); }); diff --git a/projects/addon-commerce/constants/default-card-validator.ts b/projects/addon-commerce/constants/default-card-validator.ts index c2f0f4e21f99..c8840e65374c 100644 --- a/projects/addon-commerce/constants/default-card-validator.ts +++ b/projects/addon-commerce/constants/default-card-validator.ts @@ -1,5 +1,5 @@ -import {isCardLengthValid, isCardNumberValid} from '@taiga-ui/addon-commerce/utils'; +import {tuiIsCardLengthValid, tuiIsCardNumberValid} from '@taiga-ui/addon-commerce/utils'; import {TuiBooleanHandler} from '@taiga-ui/cdk'; export const tuiDefaultCardValidator: TuiBooleanHandler = card => - card.length > 11 && isCardLengthValid(card) && isCardNumberValid(card); + card.length > 11 && tuiIsCardLengthValid(card) && tuiIsCardNumberValid(card); diff --git a/projects/addon-commerce/enums/index.ts b/projects/addon-commerce/enums/index.ts index 3cd57b55226f..1d4c5de2f64d 100644 --- a/projects/addon-commerce/enums/index.ts +++ b/projects/addon-commerce/enums/index.ts @@ -1,2 +1,3 @@ export * from './currency'; export * from './currency-code'; +export * from './payment-system'; diff --git a/projects/addon-commerce/enums/payment-system.ts b/projects/addon-commerce/enums/payment-system.ts new file mode 100644 index 000000000000..a966b8ead64e --- /dev/null +++ b/projects/addon-commerce/enums/payment-system.ts @@ -0,0 +1,9 @@ +export const enum TuiPaymentSystem { + Visa = 'visa', + Electron = 'electron', + Mastercard = 'mastercard', + Maestro = 'maestro', + Mir = 'mir', +} + +export type TuiPaymentSystemT = 'visa' | 'electron' | 'mastercard' | 'maestro' | 'mir'; diff --git a/projects/addon-commerce/types/index.ts b/projects/addon-commerce/types/index.ts index ed9ffe911648..35d5c6d16dc1 100644 --- a/projects/addon-commerce/types/index.ts +++ b/projects/addon-commerce/types/index.ts @@ -1,4 +1,3 @@ export * from './code-length'; export * from './currency-variants'; export * from './money-sign'; -export * from './payment-system'; diff --git a/projects/addon-commerce/types/payment-system.ts b/projects/addon-commerce/types/payment-system.ts deleted file mode 100644 index e5b1a3513c44..000000000000 --- a/projects/addon-commerce/types/payment-system.ts +++ /dev/null @@ -1 +0,0 @@ -export type TuiPaymentSystem = 'visa' | 'electron' | 'mastercard' | 'maestro' | 'mir'; diff --git a/projects/addon-commerce/utils/get-payment-system.ts b/projects/addon-commerce/utils/get-payment-system.ts index 714a57dd32d5..0a125600398c 100644 --- a/projects/addon-commerce/utils/get-payment-system.ts +++ b/projects/addon-commerce/utils/get-payment-system.ts @@ -1,4 +1,4 @@ -import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/types'; +import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums'; export function tuiGetPaymentSystem(cardNumber: string): TuiPaymentSystem | null { if (cardNumber === '') { @@ -11,23 +11,23 @@ export function tuiGetPaymentSystem(cardNumber: string): TuiPaymentSystem | null const four = Number.parseInt(cardNumber.slice(0, 4), 10); if (tuiIsMaestro(three, two, one)) { - return 'maestro'; + return TuiPaymentSystem.Maestro; } if (tuiIsMastercard(four, two, one)) { - return 'mastercard'; + return TuiPaymentSystem.Mastercard; } if (tuiIsMir(four)) { - return 'mir'; + return TuiPaymentSystem.Mir; } if (tuiIsElectron(four)) { - return 'electron'; + return TuiPaymentSystem.Electron; } if (tuiIsVisa(one)) { - return 'visa'; + return TuiPaymentSystem.Visa; } return null; diff --git a/projects/addon-commerce/utils/is-card-length-valid.ts b/projects/addon-commerce/utils/is-card-length-valid.ts index c02149f11927..95cb2c21e246 100644 --- a/projects/addon-commerce/utils/is-card-length-valid.ts +++ b/projects/addon-commerce/utils/is-card-length-valid.ts @@ -1,27 +1,26 @@ +import {TuiPaymentSystem} from '@taiga-ui/addon-commerce/enums'; + import {tuiGetPaymentSystem} from './get-payment-system'; /** - * @deprecated: use {@link tuiIsCardLengthValid} instead * Validates card number length using payment system dictionary */ // eslint-disable-next-line @typescript-eslint/naming-convention -export function isCardLengthValid(cardNumber: string): boolean { +export function tuiIsCardLengthValid(cardNumber: string): boolean { const {length} = cardNumber; const paymentSystem = tuiGetPaymentSystem(cardNumber); switch (paymentSystem) { - case 'electron': + case TuiPaymentSystem.Electron: return length === 16; - case 'maestro': + case TuiPaymentSystem.Maestro: return length > 11 && length < 20; - case 'mastercard': - case 'mir': + case TuiPaymentSystem.Mastercard: + case TuiPaymentSystem.Mir: return length > 15 && length < 20; - case 'visa': + case TuiPaymentSystem.Visa: return length > 12 && length < 20; default: return length > 8 && length < 20; } } - -export const tuiIsCardLengthValid = isCardLengthValid; diff --git a/projects/addon-commerce/utils/is-card-number-valid.ts b/projects/addon-commerce/utils/is-card-number-valid.ts index 58f817aae97f..7de572f69c30 100644 --- a/projects/addon-commerce/utils/is-card-number-valid.ts +++ b/projects/addon-commerce/utils/is-card-number-valid.ts @@ -1,11 +1,10 @@ import {TUI_NON_DIGITS_REGEXP} from '@taiga-ui/core'; /** - * @deprecated: use {@link tuiIsCardNumberValid} instead * Validates card number using Luhn algorithm */ // eslint-disable-next-line @typescript-eslint/naming-convention -export function isCardNumberValid(value: string | number): boolean { +export function tuiIsCardNumberValid(value: string | number): boolean { const cardNumber = String(value).replace(TUI_NON_DIGITS_REGEXP, ''); const {length} = cardNumber; @@ -23,5 +22,3 @@ export function isCardNumberValid(value: string | number): boolean { return !(arr.reduce((a, b) => a + b, 0) % 10); } - -export const tuiIsCardNumberValid = isCardNumberValid; diff --git a/projects/addon-commerce/utils/test/get-payment-system.spec.ts b/projects/addon-commerce/utils/test/get-payment-system.spec.ts index 06edf714d14d..025f61735a20 100644 --- a/projects/addon-commerce/utils/test/get-payment-system.spec.ts +++ b/projects/addon-commerce/utils/test/get-payment-system.spec.ts @@ -1,105 +1,107 @@ +import {TuiPaymentSystem} from '@taiga-ui/addon-commerce'; + import {tuiGetPaymentSystem} from '../get-payment-system'; describe('getPaymentSystem', () => { describe('Visa', () => { it('4', () => { - expect(tuiGetPaymentSystem('4000')).toBe('visa'); + expect(tuiGetPaymentSystem('4000')).toBe(TuiPaymentSystem.Visa); }); }); - describe('Electron', () => { + describe(TuiPaymentSystem.Electron, () => { it('4026', () => { - expect(tuiGetPaymentSystem('4026')).toBe('electron'); + expect(tuiGetPaymentSystem('4026')).toBe(TuiPaymentSystem.Electron); }); it('4175', () => { - expect(tuiGetPaymentSystem('4175')).toBe('electron'); + expect(tuiGetPaymentSystem('4175')).toBe(TuiPaymentSystem.Electron); }); it('4405', () => { - expect(tuiGetPaymentSystem('4405')).toBe('electron'); + expect(tuiGetPaymentSystem('4405')).toBe(TuiPaymentSystem.Electron); }); it('4508', () => { - expect(tuiGetPaymentSystem('4508')).toBe('electron'); + expect(tuiGetPaymentSystem('4508')).toBe(TuiPaymentSystem.Electron); }); it('4844', () => { - expect(tuiGetPaymentSystem('4844')).toBe('electron'); + expect(tuiGetPaymentSystem('4844')).toBe(TuiPaymentSystem.Electron); }); it('4913', () => { - expect(tuiGetPaymentSystem('4913')).toBe('electron'); + expect(tuiGetPaymentSystem('4913')).toBe(TuiPaymentSystem.Electron); }); it('4917', () => { - expect(tuiGetPaymentSystem('4917')).toBe('electron'); + expect(tuiGetPaymentSystem('4917')).toBe(TuiPaymentSystem.Electron); }); }); - describe('Mastercard', () => { + describe(TuiPaymentSystem.Mastercard, () => { it('2221', () => { - expect(tuiGetPaymentSystem('2221')).toBe('mastercard'); + expect(tuiGetPaymentSystem('2221')).toBe(TuiPaymentSystem.Mastercard); }); it('2720', () => { - expect(tuiGetPaymentSystem('2720')).toBe('mastercard'); + expect(tuiGetPaymentSystem('2720')).toBe(TuiPaymentSystem.Mastercard); }); it('5100', () => { - expect(tuiGetPaymentSystem('5100')).toBe('mastercard'); + expect(tuiGetPaymentSystem('5100')).toBe(TuiPaymentSystem.Mastercard); }); it('5500', () => { - expect(tuiGetPaymentSystem('5500')).toBe('mastercard'); + expect(tuiGetPaymentSystem('5500')).toBe(TuiPaymentSystem.Mastercard); }); it('5', () => { - expect(tuiGetPaymentSystem('5')).toBe('mastercard'); + expect(tuiGetPaymentSystem('5')).toBe(TuiPaymentSystem.Mastercard); }); }); - describe('Maestro', () => { + describe(TuiPaymentSystem.Maestro, () => { it('5000', () => { - expect(tuiGetPaymentSystem('5000')).toBe('maestro'); + expect(tuiGetPaymentSystem('5000')).toBe(TuiPaymentSystem.Maestro); }); it('5090', () => { - expect(tuiGetPaymentSystem('5090')).toBe('maestro'); + expect(tuiGetPaymentSystem('5090')).toBe(TuiPaymentSystem.Maestro); }); it('5600', () => { - expect(tuiGetPaymentSystem('5600')).toBe('maestro'); + expect(tuiGetPaymentSystem('5600')).toBe(TuiPaymentSystem.Maestro); }); it('5890', () => { - expect(tuiGetPaymentSystem('5890')).toBe('maestro'); + expect(tuiGetPaymentSystem('5890')).toBe(TuiPaymentSystem.Maestro); }); it('6000', () => { - expect(tuiGetPaymentSystem('6000')).toBe('maestro'); + expect(tuiGetPaymentSystem('6000')).toBe(TuiPaymentSystem.Maestro); }); it('50', () => { - expect(tuiGetPaymentSystem('50')).toBe('maestro'); + expect(tuiGetPaymentSystem('50')).toBe(TuiPaymentSystem.Maestro); }); it('56', () => { - expect(tuiGetPaymentSystem('56')).toBe('maestro'); + expect(tuiGetPaymentSystem('56')).toBe(TuiPaymentSystem.Maestro); }); it('58', () => { - expect(tuiGetPaymentSystem('58')).toBe('maestro'); + expect(tuiGetPaymentSystem('58')).toBe(TuiPaymentSystem.Maestro); }); }); describe('Mir', () => { it('2200', () => { - expect(tuiGetPaymentSystem('2200')).toBe('mir'); + expect(tuiGetPaymentSystem('2200')).toBe(TuiPaymentSystem.Mir); }); it('2204', () => { - expect(tuiGetPaymentSystem('2204')).toBe('mir'); + expect(tuiGetPaymentSystem('2204')).toBe(TuiPaymentSystem.Mir); }); }); }); diff --git a/projects/addon-commerce/utils/test/is-card-length-valid.spec.ts b/projects/addon-commerce/utils/test/is-card-length-valid.spec.ts index a15a0755f423..96d31cba7f1e 100644 --- a/projects/addon-commerce/utils/test/is-card-length-valid.spec.ts +++ b/projects/addon-commerce/utils/test/is-card-length-valid.spec.ts @@ -1,87 +1,87 @@ -import {isCardLengthValid} from '../is-card-length-valid'; +import {tuiIsCardLengthValid} from '../is-card-length-valid'; describe('isCardLengthValid', () => { describe('Visa', () => { it('cannot be 12 digits long', () => { - expect(isCardLengthValid('400000000000')).toBe(false); + expect(tuiIsCardLengthValid('400000000000')).toBe(false); }); it('can be 13 digits long', () => { - expect(isCardLengthValid('4000000000000')).toBe(true); + expect(tuiIsCardLengthValid('4000000000000')).toBe(true); }); it('can be 19 digits long', () => { - expect(isCardLengthValid('4000000000000000000')).toBe(true); + expect(tuiIsCardLengthValid('4000000000000000000')).toBe(true); }); }); describe('Electron', () => { it('cannot be 15 digits long', () => { - expect(isCardLengthValid('402600000000000')).toBe(false); + expect(tuiIsCardLengthValid('402600000000000')).toBe(false); }); it('can only be 16 digits long', () => { - expect(isCardLengthValid('4026000000000000')).toBe(true); + expect(tuiIsCardLengthValid('4026000000000000')).toBe(true); }); it('cannot be 17 digits long', () => { - expect(isCardLengthValid('40260000000000000')).toBe(false); + expect(tuiIsCardLengthValid('40260000000000000')).toBe(false); }); }); describe('Mastercard', () => { it('cannot be 15 digits long', () => { - expect(isCardLengthValid('510000000000000')).toBe(false); + expect(tuiIsCardLengthValid('510000000000000')).toBe(false); }); it('can be 16 digits long', () => { - expect(isCardLengthValid('5100000000000000')).toBe(true); + expect(tuiIsCardLengthValid('5100000000000000')).toBe(true); }); it('can be 19 digits long', () => { - expect(isCardLengthValid('5100000000000000000')).toBe(true); + expect(tuiIsCardLengthValid('5100000000000000000')).toBe(true); }); }); describe('Maestro', () => { it('can be 12 digits long', () => { - expect(isCardLengthValid('560000000000')).toBe(true); + expect(tuiIsCardLengthValid('560000000000')).toBe(true); }); it('can be 19 digits long', () => { - expect(isCardLengthValid('5600000000000000000')).toBe(true); + expect(tuiIsCardLengthValid('5600000000000000000')).toBe(true); }); }); describe('Mir', () => { it('cannot be 15 digits long', () => { - expect(isCardLengthValid('220000000000000')).toBe(false); + expect(tuiIsCardLengthValid('220000000000000')).toBe(false); }); it('can be 16 digits long', () => { - expect(isCardLengthValid('2200000000000000')).toBe(true); + expect(tuiIsCardLengthValid('2200000000000000')).toBe(true); }); it('can be 19 digits long', () => { - expect(isCardLengthValid('2200000000000000000')).toBe(true); + expect(tuiIsCardLengthValid('2200000000000000000')).toBe(true); }); }); describe('Unknown', () => { it('cannot be 7 digits long', () => { - expect(isCardLengthValid('3566002')).toBe(false); + expect(tuiIsCardLengthValid('3566002')).toBe(false); }); it('can be 16 digits long', () => { - expect(isCardLengthValid('3566002020360505')).toBe(true); + expect(tuiIsCardLengthValid('3566002020360505')).toBe(true); }); it('can be 19 digits long', () => { - expect(isCardLengthValid('3566002020360505000')).toBe(true); + expect(tuiIsCardLengthValid('3566002020360505000')).toBe(true); }); it('cannot be 20 digits long', () => { - expect(isCardLengthValid('35660020203605050000')).toBe(false); + expect(tuiIsCardLengthValid('35660020203605050000')).toBe(false); }); }); }); diff --git a/projects/addon-commerce/validators/card-number.validator.ts b/projects/addon-commerce/validators/card-number.validator.ts index 755f51114118..2ccdae8c79e7 100644 --- a/projects/addon-commerce/validators/card-number.validator.ts +++ b/projects/addon-commerce/validators/card-number.validator.ts @@ -1,11 +1,11 @@ import {AbstractControl, ValidationErrors} from '@angular/forms'; -import {isCardNumberValid} from '@taiga-ui/addon-commerce/utils'; +import {tuiIsCardNumberValid} from '@taiga-ui/addon-commerce/utils'; import {TuiValidationError} from '@taiga-ui/cdk'; export function tuiCardNumberValidator({ value, }: AbstractControl): ValidationErrors | null { - return value?.card && !isCardNumberValid(value.card) + return value?.card && !tuiIsCardNumberValid(value.card) ? {card: new TuiValidationError('Invalid card number')} : null; } diff --git a/projects/addon-commerce/validators/luhn.validator.ts b/projects/addon-commerce/validators/luhn.validator.ts index d4aa9b308f9f..b0de3e985f48 100644 --- a/projects/addon-commerce/validators/luhn.validator.ts +++ b/projects/addon-commerce/validators/luhn.validator.ts @@ -1,10 +1,12 @@ import {AbstractControl, ValidatorFn} from '@angular/forms'; -import {isCardNumberValid} from '@taiga-ui/addon-commerce/utils'; +import {tuiIsCardNumberValid} from '@taiga-ui/addon-commerce/utils'; import {TuiValidationError} from '@taiga-ui/cdk'; import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; export function tuiCreateLuhnValidator(message: PolymorpheusContent): ValidatorFn { return ({value}: AbstractControl) => { - return isCardNumberValid(value) ? null : {luhn: new TuiValidationError(message)}; + return tuiIsCardNumberValid(value) + ? null + : {luhn: new TuiValidationError(message)}; }; } diff --git a/projects/cdk/schematics/ng-update/constants/enums.ts b/projects/cdk/schematics/ng-update/constants/enums.ts index a1c0c15cb5be..f2e67209c304 100644 --- a/projects/cdk/schematics/ng-update/constants/enums.ts +++ b/projects/cdk/schematics/ng-update/constants/enums.ts @@ -5,17 +5,6 @@ interface ReplacementEnum { } export const ENUMS_TO_REPLACE: ReplacementEnum[] = [ - { - name: 'TuiPaymentSystem', - replaceValues: { - Visa: 'visa', - Electron: 'electron', - Mastercard: 'mastercard', - Maestro: 'maestro', - Mir: 'mir', - }, - keepAsType: true, - }, { name: 'TuiTextAlign', replaceValues: { diff --git a/projects/demo/src/modules/components/card/card.component.ts b/projects/demo/src/modules/components/card/card.component.ts index 2cb8bccc2068..95b2e5f08228 100644 --- a/projects/demo/src/modules/components/card/card.component.ts +++ b/projects/demo/src/modules/components/card/card.component.ts @@ -45,10 +45,10 @@ export class ExampleTuiCardComponent { }; paymentSystemVariants: readonly TuiPaymentSystem[] = [ - 'visa', - 'maestro', - 'mastercard', - 'mir', + TuiPaymentSystem.Visa, + TuiPaymentSystem.Maestro, + TuiPaymentSystem.Mastercard, + TuiPaymentSystem.Mir, ]; brandLogoVariants = ['', ...BRAND_LOGOS]; diff --git a/projects/demo/src/modules/components/card/examples/3/index.ts b/projects/demo/src/modules/components/card/examples/3/index.ts index 9fe2766d09b4..cc31b6ff59c8 100644 --- a/projects/demo/src/modules/components/card/examples/3/index.ts +++ b/projects/demo/src/modules/components/card/examples/3/index.ts @@ -11,6 +11,6 @@ import {TuiPaymentSystem} from '@taiga-ui/addon-commerce'; encapsulation, }) export class TuiCardExample3 { - readonly paymentSystem: TuiPaymentSystem = 'mir'; + readonly paymentSystem = TuiPaymentSystem.Mir; readonly brandLogo = 'https://ng-web-apis.github.io/dist/assets/images/web-api.svg'; }