@xsolla/payment-client-core 0.2.66 → 0.2.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/core/payment/form/converters/birth-date/birth-date.converter.mjs +6 -5
- package/esm2022/lib/core/payment/form/converters/card-number/card-number.converter.mjs +5 -4
- package/esm2022/lib/core/payment/form/converters/checkbox/checkbox.converter.mjs +6 -2
- package/esm2022/lib/core/payment/form/converters/converter.abstract.mjs +6 -2
- package/esm2022/lib/core/payment/form/converters/cpf-name/cpf-name.converter.mjs +6 -5
- package/esm2022/lib/core/payment/form/converters/cvv/cvv.converter.mjs +5 -2
- package/esm2022/lib/core/payment/form/converters/street-number/street-number.converter.mjs +5 -2
- package/esm2022/lib/core/payment/form/converters/zip/zip.converter.mjs +8 -7
- package/esm2022/lib/core/payment/form/overrided-fields/fields-allowed-to-override.mjs +2 -1
- package/esm2022/lib/core/payment/form/overrided-fields/override-field-config.mjs +7 -2
- package/esm2022/lib/core/payment/form/validators/birth-date/birth-date.validator.mjs +6 -2
- package/esm2022/lib/core/payment/form/validators/card-expiration-date-validator/card-expiration-date.validator.mjs +31 -10
- package/esm2022/lib/core/payment/form/validators/card-month/card-month.validator.mjs +20 -7
- package/esm2022/lib/core/payment/form/validators/card-year/card-year.validator.mjs +20 -7
- package/esm2022/lib/core/payment/form/validators/convert.function.mjs +7 -6
- package/esm2022/lib/core/payment/form/validators/coupon/coupon-validator.mjs +6 -3
- package/esm2022/lib/core/payment/form/validators/credit-card-length/credit-card-max-length.validator.mjs +37 -0
- package/esm2022/lib/core/payment/form/validators/credit-card-length/credit-card-min-length.validator.mjs +13 -8
- package/esm2022/lib/core/payment/form/validators/email/email-validator.mjs +5 -2
- package/esm2022/lib/core/payment/form/validators/luhn-formula-validator/luhn-formula.validator.mjs +6 -2
- package/esm2022/lib/core/payment/form/validators/max-length-validator.mjs +6 -2
- package/esm2022/lib/core/payment/form/validators/min-length-validator.mjs +6 -2
- package/esm2022/lib/core/payment/form/validators/phone-validator.mjs +5 -2
- package/esm2022/lib/core/payment/form/validators/required/required.validator.mjs +5 -2
- package/esm2022/lib/core/payment/form/validators/validation-error-id.enum.mjs +24 -0
- package/esm2022/lib/core/payment/form/validators/validation-error-params.interface.mjs +2 -0
- package/esm2022/lib/core/payment/form/validators/validation-error.interface.mjs +1 -1
- package/esm2022/lib/core/payment/form/validators/validators.module.mjs +5 -4
- package/esm2022/lib/core/type-guards/is-object.function.mjs +4 -0
- package/fesm2022/xsolla-payment-client-core.mjs +211 -70
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/converters/card-number/card-number.converter.d.ts +2 -1
- package/lib/core/payment/form/validators/convert.function.d.ts +2 -1
- package/lib/core/payment/form/validators/credit-card-length/credit-card-max-length.validator.d.ts +12 -0
- package/lib/core/payment/form/validators/credit-card-length/credit-card-min-length.validator.d.ts +2 -2
- package/lib/core/payment/form/validators/validation-error-id.enum.d.ts +22 -0
- package/lib/core/payment/form/validators/validation-error-params.interface.d.ts +6 -0
- package/lib/core/payment/form/validators/validation-error.interface.d.ts +2 -0
- package/lib/core/type-guards/is-object.function.d.ts +1 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.2.68.tgz +0 -0
- package/xsolla-payment-client-core-0.2.66.tgz +0 -0
|
@@ -712,6 +712,7 @@ var ErrorTags;
|
|
|
712
712
|
|
|
713
713
|
const fieldsAllowedToOverride = new Set([
|
|
714
714
|
FieldNames.allowSubscription,
|
|
715
|
+
FieldNames.allowSave,
|
|
715
716
|
]);
|
|
716
717
|
|
|
717
718
|
function isXpsBoolean(value) {
|
|
@@ -723,7 +724,11 @@ function isXpsBoolean(value) {
|
|
|
723
724
|
* We can extend this configuration with additional fields in the future.
|
|
724
725
|
*/
|
|
725
726
|
const overrideFieldConfigs = {
|
|
726
|
-
allowSubscription: {
|
|
727
|
+
[FieldNames.allowSubscription]: {
|
|
728
|
+
validator: isXpsBoolean,
|
|
729
|
+
defaultValue: "0" /* XpsBoolean.false */,
|
|
730
|
+
},
|
|
731
|
+
[FieldNames.allowSave]: {
|
|
727
732
|
validator: isXpsBoolean,
|
|
728
733
|
defaultValue: "0" /* XpsBoolean.false */,
|
|
729
734
|
},
|
|
@@ -3299,28 +3304,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3299
3304
|
args: [syncResponseFactoryToken]
|
|
3300
3305
|
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
3301
3306
|
|
|
3302
|
-
function
|
|
3307
|
+
function isObject(value) {
|
|
3308
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3311
|
+
function convert(validator, message, params) {
|
|
3303
3312
|
return (control) => {
|
|
3304
3313
|
const errors = validator(control);
|
|
3305
|
-
if (!errors)
|
|
3306
|
-
return
|
|
3307
|
-
}
|
|
3314
|
+
if (!errors)
|
|
3315
|
+
return null;
|
|
3308
3316
|
const firstErrorKey = Object.keys(errors)[0];
|
|
3309
3317
|
const firstError = errors[firstErrorKey];
|
|
3310
|
-
const error =
|
|
3318
|
+
const error = isObject(firstError) ? firstError : {};
|
|
3311
3319
|
error.message = message;
|
|
3320
|
+
error.params = params;
|
|
3312
3321
|
errors[firstErrorKey] = error;
|
|
3313
3322
|
return errors;
|
|
3314
3323
|
};
|
|
3315
3324
|
}
|
|
3316
3325
|
|
|
3326
|
+
var ValidationErrorId;
|
|
3327
|
+
(function (ValidationErrorId) {
|
|
3328
|
+
ValidationErrorId["birthDatePattern"] = "birthDatePattern";
|
|
3329
|
+
ValidationErrorId["expirationLength"] = "expirationLength";
|
|
3330
|
+
ValidationErrorId["expirationMonthPattern"] = "expirationMonthPattern";
|
|
3331
|
+
ValidationErrorId["expirationMinMonth"] = "expirationMinMonth";
|
|
3332
|
+
ValidationErrorId["expirationMaxMonth"] = "expirationMaxMonth";
|
|
3333
|
+
ValidationErrorId["expirationYearPattern"] = "expirationYearPattern";
|
|
3334
|
+
ValidationErrorId["expirationMinYear"] = "expirationMinYear";
|
|
3335
|
+
ValidationErrorId["expirationMaxYear"] = "expirationMaxYear";
|
|
3336
|
+
ValidationErrorId["couponPattern"] = "couponPattern";
|
|
3337
|
+
ValidationErrorId["emailPattern"] = "emailPattern";
|
|
3338
|
+
ValidationErrorId["cardNumberPattern"] = "cardNumberPattern";
|
|
3339
|
+
ValidationErrorId["required"] = "required";
|
|
3340
|
+
ValidationErrorId["minLength"] = "minLength";
|
|
3341
|
+
ValidationErrorId["maxLength"] = "maxLength";
|
|
3342
|
+
ValidationErrorId["cpfNumberPattern"] = "cpfNumberPattern";
|
|
3343
|
+
ValidationErrorId["cvvPattern"] = "cvvPattern";
|
|
3344
|
+
ValidationErrorId["phonePattern"] = "phonePattern";
|
|
3345
|
+
ValidationErrorId["buildingNumberPattern"] = "buildingNumberPattern";
|
|
3346
|
+
ValidationErrorId["zipPattern"] = "zipPattern";
|
|
3347
|
+
ValidationErrorId["dataPattern"] = "dataPattern";
|
|
3348
|
+
})(ValidationErrorId || (ValidationErrorId = {}));
|
|
3349
|
+
|
|
3317
3350
|
const emailRegexp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-line
|
|
3318
3351
|
function convertedEmailValidator() {
|
|
3319
|
-
return convert(Validators.pattern(emailRegexp), 'Enter a valid email'
|
|
3352
|
+
return convert(Validators.pattern(emailRegexp), 'Enter a valid email', {
|
|
3353
|
+
id: ValidationErrorId.emailPattern,
|
|
3354
|
+
});
|
|
3320
3355
|
}
|
|
3321
3356
|
|
|
3322
3357
|
function convertedRequiredValidator() {
|
|
3323
|
-
return convert(Validators.required, 'Required'
|
|
3358
|
+
return convert(Validators.required, 'Required', {
|
|
3359
|
+
id: ValidationErrorId.required,
|
|
3360
|
+
});
|
|
3324
3361
|
}
|
|
3325
3362
|
|
|
3326
3363
|
class Converter {
|
|
@@ -3353,7 +3390,10 @@ class Converter {
|
|
|
3353
3390
|
const errorMessage = field.validation_error_msg
|
|
3354
3391
|
? field.validation_error_msg
|
|
3355
3392
|
: 'Enter valid data';
|
|
3356
|
-
validators.push(convert(Validators.pattern(pattern), errorMessage
|
|
3393
|
+
validators.push(convert(Validators.pattern(pattern), errorMessage, {
|
|
3394
|
+
id: ValidationErrorId.dataPattern,
|
|
3395
|
+
defaultMessage: field.validation_error_msg,
|
|
3396
|
+
}));
|
|
3357
3397
|
}
|
|
3358
3398
|
}
|
|
3359
3399
|
return validators;
|
|
@@ -3444,6 +3484,20 @@ class TextControlConfig extends ControlConfig {
|
|
|
3444
3484
|
}
|
|
3445
3485
|
}
|
|
3446
3486
|
|
|
3487
|
+
function minLengthValidator(minLength) {
|
|
3488
|
+
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`, {
|
|
3489
|
+
id: ValidationErrorId.minLength,
|
|
3490
|
+
minLength,
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
function maxLengthValidator(maxLength) {
|
|
3495
|
+
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`, {
|
|
3496
|
+
id: ValidationErrorId.maxLength,
|
|
3497
|
+
maxLength,
|
|
3498
|
+
});
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3447
3501
|
const restrictedValueValidator = (restrictedValue) => {
|
|
3448
3502
|
return ({ value }) => {
|
|
3449
3503
|
return value !== restrictedValue ? null : { valueAllowed: false };
|
|
@@ -3466,12 +3520,11 @@ class ZipConverter extends Converter {
|
|
|
3466
3520
|
const maxLength = this.isUsCountry ? this.usCountryLength : this.maxLength;
|
|
3467
3521
|
const validators = super
|
|
3468
3522
|
.getValidators(field)
|
|
3469
|
-
.concat([
|
|
3470
|
-
convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
|
|
3471
|
-
convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`),
|
|
3472
|
-
]);
|
|
3523
|
+
.concat([minLengthValidator(minLength), maxLengthValidator(maxLength)]);
|
|
3473
3524
|
if (this.isUsCountry) {
|
|
3474
|
-
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'
|
|
3525
|
+
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code', {
|
|
3526
|
+
id: ValidationErrorId.zipPattern,
|
|
3527
|
+
}));
|
|
3475
3528
|
}
|
|
3476
3529
|
return validators;
|
|
3477
3530
|
}
|
|
@@ -3524,7 +3577,10 @@ const luhnFormulaValidator = ({ value }) => {
|
|
|
3524
3577
|
}
|
|
3525
3578
|
const error = {
|
|
3526
3579
|
rewritableError: {
|
|
3527
|
-
message:
|
|
3580
|
+
message: 'Enter a valid card number',
|
|
3581
|
+
params: {
|
|
3582
|
+
id: ValidationErrorId.cardNumberPattern,
|
|
3583
|
+
},
|
|
3528
3584
|
},
|
|
3529
3585
|
};
|
|
3530
3586
|
if (/[^0-9 -]+/.test(value)) {
|
|
@@ -3561,6 +3617,37 @@ class CardNumberConfig extends ControlConfig {
|
|
|
3561
3617
|
}
|
|
3562
3618
|
}
|
|
3563
3619
|
|
|
3620
|
+
class CreditCardMaxLengthValidator {
|
|
3621
|
+
constructor(creditService) {
|
|
3622
|
+
this.creditService = creditService;
|
|
3623
|
+
this.validate = (field) => {
|
|
3624
|
+
if (isEmptyInputValue(field.value) || !isString(field.value)) {
|
|
3625
|
+
return null;
|
|
3626
|
+
}
|
|
3627
|
+
const length = field.value.length;
|
|
3628
|
+
const cardType = this.creditService.getTypeByNumber(field.value);
|
|
3629
|
+
const { maxLength } = this.creditService.getCreditCardSettings(cardType);
|
|
3630
|
+
if (length <= maxLength)
|
|
3631
|
+
return null;
|
|
3632
|
+
return {
|
|
3633
|
+
rewritableError: {
|
|
3634
|
+
message: `Enter no more than ${maxLength} characters`,
|
|
3635
|
+
number: maxLength,
|
|
3636
|
+
params: {
|
|
3637
|
+
id: ValidationErrorId.maxLength,
|
|
3638
|
+
maxLength,
|
|
3639
|
+
},
|
|
3640
|
+
},
|
|
3641
|
+
};
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3644
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardMaxLengthValidator, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3645
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardMaxLengthValidator }); }
|
|
3646
|
+
}
|
|
3647
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardMaxLengthValidator, decorators: [{
|
|
3648
|
+
type: Injectable
|
|
3649
|
+
}], ctorParameters: () => [{ type: CreditCardService }] });
|
|
3650
|
+
|
|
3564
3651
|
class CreditCardMinLengthValidator {
|
|
3565
3652
|
constructor(creditService) {
|
|
3566
3653
|
this.creditService = creditService;
|
|
@@ -3571,14 +3658,18 @@ class CreditCardMinLengthValidator {
|
|
|
3571
3658
|
const length = field.value.length;
|
|
3572
3659
|
const cardType = this.creditService.getTypeByNumber(field.value);
|
|
3573
3660
|
const { minLength } = this.creditService.getCreditCardSettings(cardType);
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3661
|
+
if (length >= minLength)
|
|
3662
|
+
return null;
|
|
3663
|
+
return {
|
|
3664
|
+
rewritableError: {
|
|
3665
|
+
message: `Enter at least ${minLength} characters`,
|
|
3666
|
+
number: minLength,
|
|
3667
|
+
params: {
|
|
3668
|
+
id: ValidationErrorId.minLength,
|
|
3669
|
+
minLength,
|
|
3579
3670
|
},
|
|
3580
|
-
}
|
|
3581
|
-
|
|
3671
|
+
},
|
|
3672
|
+
};
|
|
3582
3673
|
};
|
|
3583
3674
|
}
|
|
3584
3675
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardMinLengthValidator, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -3619,12 +3710,12 @@ class CardNumberConverter extends Converter {
|
|
|
3619
3710
|
getDataType() {
|
|
3620
3711
|
return 'text';
|
|
3621
3712
|
}
|
|
3622
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardNumberConverter, deps: [{ token: SyncService }, { token:
|
|
3713
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardNumberConverter, deps: [{ token: SyncService }, { token: CreditCardMaxLengthValidator }, { token: CreditCardMinLengthValidator }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3623
3714
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardNumberConverter }); }
|
|
3624
3715
|
}
|
|
3625
3716
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardNumberConverter, decorators: [{
|
|
3626
3717
|
type: Injectable
|
|
3627
|
-
}], ctorParameters: () => [{ type: SyncService }, { type:
|
|
3718
|
+
}], ctorParameters: () => [{ type: SyncService }, { type: CreditCardMaxLengthValidator }, { type: CreditCardMinLengthValidator }] });
|
|
3628
3719
|
|
|
3629
3720
|
const maxMonths$1 = 12;
|
|
3630
3721
|
const getMinMonth$1 = (parsedYear) => {
|
|
@@ -3634,9 +3725,10 @@ const getMinMonth$1 = (parsedYear) => {
|
|
|
3634
3725
|
minMonth = year === today.getFullYear() ? today.getMonth() + 1 : 1;
|
|
3635
3726
|
return minMonth;
|
|
3636
3727
|
};
|
|
3637
|
-
const sendErrMessage$2 = (
|
|
3728
|
+
const sendErrMessage$2 = (message, params) => ({
|
|
3638
3729
|
cardMonthExpiration: {
|
|
3639
|
-
message
|
|
3730
|
+
message,
|
|
3731
|
+
params,
|
|
3640
3732
|
},
|
|
3641
3733
|
});
|
|
3642
3734
|
function cardMonthValidator(formState) {
|
|
@@ -3648,16 +3740,27 @@ function cardMonthValidator(formState) {
|
|
|
3648
3740
|
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
3649
3741
|
const fieldCommonLength = 2;
|
|
3650
3742
|
if (value.length !== fieldCommonLength) {
|
|
3651
|
-
return sendErrMessage$2(`Enter ${fieldCommonLength} characters
|
|
3743
|
+
return sendErrMessage$2(`Enter ${fieldCommonLength} characters`, {
|
|
3744
|
+
id: ValidationErrorId.expirationLength,
|
|
3745
|
+
requiredLength: fieldCommonLength,
|
|
3746
|
+
});
|
|
3652
3747
|
}
|
|
3653
3748
|
if (!twoDigitsRegex.test(value)) {
|
|
3654
|
-
return sendErrMessage$2(
|
|
3749
|
+
return sendErrMessage$2('Enter a valid expiration month', {
|
|
3750
|
+
id: ValidationErrorId.expirationMonthPattern,
|
|
3751
|
+
});
|
|
3655
3752
|
}
|
|
3656
3753
|
if (Number(value) < minMonth) {
|
|
3657
|
-
return sendErrMessage$2(`Enter a month greater than or equal to ${minMonth}
|
|
3754
|
+
return sendErrMessage$2(`Enter a month greater than or equal to ${minMonth}`, {
|
|
3755
|
+
id: ValidationErrorId.expirationMinMonth,
|
|
3756
|
+
minMonth,
|
|
3757
|
+
});
|
|
3658
3758
|
}
|
|
3659
3759
|
if (Number(value) > maxMonths$1) {
|
|
3660
|
-
return sendErrMessage$2(`Enter a month less than or equal to ${maxMonths$1}
|
|
3760
|
+
return sendErrMessage$2(`Enter a month less than or equal to ${maxMonths$1}`, {
|
|
3761
|
+
id: ValidationErrorId.expirationMaxMonth,
|
|
3762
|
+
maxMonth: maxMonths$1,
|
|
3763
|
+
});
|
|
3661
3764
|
}
|
|
3662
3765
|
return null;
|
|
3663
3766
|
};
|
|
@@ -3704,7 +3807,9 @@ class CvvConverter extends Converter {
|
|
|
3704
3807
|
getValidators(field, formState) {
|
|
3705
3808
|
const validators = super.getValidators(field);
|
|
3706
3809
|
const activeCardType = formState ? formState.activeCardType : null;
|
|
3707
|
-
const getPatternValidator = (pattern) => convert(Validators.pattern(pattern),
|
|
3810
|
+
const getPatternValidator = (pattern) => convert(Validators.pattern(pattern), 'Enter a valid CVV/CVC', {
|
|
3811
|
+
id: ValidationErrorId.cvvPattern,
|
|
3812
|
+
});
|
|
3708
3813
|
switch (activeCardType) {
|
|
3709
3814
|
case CreditCardTypes.AMERICAN_EXPRESS: {
|
|
3710
3815
|
this.maxFieldLength = 4;
|
|
@@ -3765,7 +3870,10 @@ const birthdateValidator = ({ value }) => {
|
|
|
3765
3870
|
}
|
|
3766
3871
|
const error = {
|
|
3767
3872
|
invalidBirthDate: {
|
|
3768
|
-
message:
|
|
3873
|
+
message: 'Enter a valid birth date',
|
|
3874
|
+
params: {
|
|
3875
|
+
id: ValidationErrorId.birthDatePattern,
|
|
3876
|
+
},
|
|
3769
3877
|
},
|
|
3770
3878
|
};
|
|
3771
3879
|
const dateArr = value.split('/');
|
|
@@ -3800,10 +3908,10 @@ class BirthDateConverter extends Converter {
|
|
|
3800
3908
|
super(syncService);
|
|
3801
3909
|
}
|
|
3802
3910
|
getValidators(field) {
|
|
3803
|
-
return super
|
|
3804
|
-
.
|
|
3805
|
-
|
|
3806
|
-
|
|
3911
|
+
return super.getValidators(field).concat([
|
|
3912
|
+
convert(Validators.pattern(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/), 'Enter a valid birth date', {
|
|
3913
|
+
id: ValidationErrorId.birthDatePattern,
|
|
3914
|
+
}),
|
|
3807
3915
|
birthdateValidator,
|
|
3808
3916
|
]);
|
|
3809
3917
|
}
|
|
@@ -3852,10 +3960,10 @@ class CpfNameConverter extends Converter {
|
|
|
3852
3960
|
super(syncService);
|
|
3853
3961
|
}
|
|
3854
3962
|
getValidators(field) {
|
|
3855
|
-
return super
|
|
3856
|
-
.
|
|
3857
|
-
|
|
3858
|
-
|
|
3963
|
+
return super.getValidators(field).concat([
|
|
3964
|
+
convert(Validators.pattern(cpfNameRegex), 'Enter a valid CPF number', {
|
|
3965
|
+
id: ValidationErrorId.cpfNumberPattern,
|
|
3966
|
+
}),
|
|
3859
3967
|
]);
|
|
3860
3968
|
}
|
|
3861
3969
|
createControlConfig(field) {
|
|
@@ -3906,7 +4014,9 @@ class StreetNumberConverter extends Converter {
|
|
|
3906
4014
|
getValidators(field, formState) {
|
|
3907
4015
|
const validators = super.getValidators(field);
|
|
3908
4016
|
if (formState?.country === 'BL') {
|
|
3909
|
-
validators.push(convert(restrictedValueValidator('0'),
|
|
4017
|
+
validators.push(convert(restrictedValueValidator('0'), 'Enter a valid building number', {
|
|
4018
|
+
id: ValidationErrorId.buildingNumberPattern,
|
|
4019
|
+
}));
|
|
3910
4020
|
}
|
|
3911
4021
|
return validators;
|
|
3912
4022
|
}
|
|
@@ -3950,7 +4060,10 @@ class CheckboxConverter extends Converter {
|
|
|
3950
4060
|
getValidators(field) {
|
|
3951
4061
|
const validators = [];
|
|
3952
4062
|
if (field.isMandatory === this.checkedValue) {
|
|
3953
|
-
validators.push(convert(restrictedValueValidator(this.uncheckedValue), '
|
|
4063
|
+
validators.push(convert(restrictedValueValidator(this.uncheckedValue), field.validation_error_msg || 'Required', {
|
|
4064
|
+
id: ValidationErrorId.required,
|
|
4065
|
+
defaultMessage: field.validation_error_msg,
|
|
4066
|
+
}));
|
|
3954
4067
|
}
|
|
3955
4068
|
return validators;
|
|
3956
4069
|
}
|
|
@@ -4063,8 +4176,10 @@ class CouponControlConfig extends ControlConfig {
|
|
|
4063
4176
|
}
|
|
4064
4177
|
}
|
|
4065
4178
|
|
|
4066
|
-
function couponValidator(message =
|
|
4067
|
-
return convert(Validators.pattern(/^[0-9a-z_-]+$/i), message
|
|
4179
|
+
function couponValidator(message = 'Enter a valid promo code') {
|
|
4180
|
+
return convert(Validators.pattern(/^[0-9a-z_-]+$/i), message, {
|
|
4181
|
+
id: ValidationErrorId.couponPattern,
|
|
4182
|
+
});
|
|
4068
4183
|
}
|
|
4069
4184
|
|
|
4070
4185
|
class CouponConverter extends Converter {
|
|
@@ -4086,9 +4201,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
4086
4201
|
type: Injectable
|
|
4087
4202
|
}], ctorParameters: () => [{ type: SyncService }] });
|
|
4088
4203
|
|
|
4089
|
-
const sendErrMessage$1 = (
|
|
4204
|
+
const sendErrMessage$1 = (message, params) => ({
|
|
4090
4205
|
cardYearExpiration: {
|
|
4091
|
-
message
|
|
4206
|
+
message,
|
|
4207
|
+
params,
|
|
4092
4208
|
},
|
|
4093
4209
|
});
|
|
4094
4210
|
const getLastCharactersInYear$1 = (str = new Date().getFullYear().toString()) => {
|
|
@@ -4105,17 +4221,28 @@ function cardYearValidator(control) {
|
|
|
4105
4221
|
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
4106
4222
|
const fieldCommonLength = 2;
|
|
4107
4223
|
if (value.length !== fieldCommonLength) {
|
|
4108
|
-
return sendErrMessage$1(`Enter ${fieldCommonLength} characters
|
|
4224
|
+
return sendErrMessage$1(`Enter ${fieldCommonLength} characters`, {
|
|
4225
|
+
id: ValidationErrorId.expirationLength,
|
|
4226
|
+
requiredLength: fieldCommonLength,
|
|
4227
|
+
});
|
|
4109
4228
|
}
|
|
4110
4229
|
if (!twoDigitsRegex.test(value)) {
|
|
4111
|
-
return sendErrMessage$1(
|
|
4230
|
+
return sendErrMessage$1('Enter a valid expiration year', {
|
|
4231
|
+
id: ValidationErrorId.expirationYearPattern,
|
|
4232
|
+
});
|
|
4112
4233
|
}
|
|
4113
4234
|
if (Number(value) < minYear) {
|
|
4114
|
-
return sendErrMessage$1(`Enter a year greater than or equal to ${minYear}
|
|
4235
|
+
return sendErrMessage$1(`Enter a year greater than or equal to ${minYear}`, {
|
|
4236
|
+
id: ValidationErrorId.expirationMinYear,
|
|
4237
|
+
minYear,
|
|
4238
|
+
});
|
|
4115
4239
|
}
|
|
4116
4240
|
const maxValidYear = minYear + maxYearsCount$1;
|
|
4117
4241
|
if (Number(value) > maxValidYear) {
|
|
4118
|
-
return sendErrMessage$1(`Enter a year less than or equal to ${maxValidYear}
|
|
4242
|
+
return sendErrMessage$1(`Enter a year less than or equal to ${maxValidYear}`, {
|
|
4243
|
+
id: ValidationErrorId.expirationMaxYear,
|
|
4244
|
+
maxYear: maxValidYear,
|
|
4245
|
+
});
|
|
4119
4246
|
}
|
|
4120
4247
|
return null;
|
|
4121
4248
|
}
|
|
@@ -4153,15 +4280,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
4153
4280
|
}], ctorParameters: () => [{ type: SyncService }] });
|
|
4154
4281
|
|
|
4155
4282
|
function phoneValidator() {
|
|
4156
|
-
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone'
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
function minLengthValidator(minLength) {
|
|
4160
|
-
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
|
|
4161
|
-
}
|
|
4162
|
-
|
|
4163
|
-
function maxLengthValidator(maxLength) {
|
|
4164
|
-
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
|
|
4283
|
+
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone', {
|
|
4284
|
+
id: ValidationErrorId.phonePattern,
|
|
4285
|
+
});
|
|
4165
4286
|
}
|
|
4166
4287
|
|
|
4167
4288
|
class PhoneControlConfig extends ControlConfig {
|
|
@@ -4210,9 +4331,10 @@ const getMinMonth = (parsedYear) => {
|
|
|
4210
4331
|
}
|
|
4211
4332
|
return minMonth;
|
|
4212
4333
|
};
|
|
4213
|
-
const sendErrMessage = (
|
|
4334
|
+
const sendErrMessage = (message, params) => ({
|
|
4214
4335
|
rewritableError: {
|
|
4215
|
-
message
|
|
4336
|
+
message,
|
|
4337
|
+
params,
|
|
4216
4338
|
},
|
|
4217
4339
|
});
|
|
4218
4340
|
const getLastCharactersInYear = (str = new Date().getFullYear().toString()) => {
|
|
@@ -4237,26 +4359,45 @@ function cardExpValidator(control) {
|
|
|
4237
4359
|
const fieldCommonLength = 4;
|
|
4238
4360
|
const trickyFieldLength = fieldCommonLength + 1;
|
|
4239
4361
|
if (value.length !== trickyFieldLength) {
|
|
4240
|
-
return sendErrMessage(`Enter ${fieldCommonLength} characters
|
|
4362
|
+
return sendErrMessage(`Enter ${fieldCommonLength} characters`, {
|
|
4363
|
+
id: ValidationErrorId.expirationLength,
|
|
4364
|
+
requiredLength: fieldCommonLength,
|
|
4365
|
+
});
|
|
4241
4366
|
}
|
|
4242
4367
|
if (!twoDigitsRegex.test(month)) {
|
|
4243
|
-
return sendErrMessage('Enter a valid expiration month'
|
|
4368
|
+
return sendErrMessage('Enter a valid expiration month', {
|
|
4369
|
+
id: ValidationErrorId.expirationMonthPattern,
|
|
4370
|
+
});
|
|
4244
4371
|
}
|
|
4245
4372
|
if (Number(month) < minMonth) {
|
|
4246
|
-
return sendErrMessage(`Enter a month greater than or equal to ${minMonth}
|
|
4373
|
+
return sendErrMessage(`Enter a month greater than or equal to ${minMonth}`, {
|
|
4374
|
+
id: ValidationErrorId.expirationMinMonth,
|
|
4375
|
+
minMonth,
|
|
4376
|
+
});
|
|
4247
4377
|
}
|
|
4248
4378
|
if (Number(month) > maxMonths) {
|
|
4249
|
-
return sendErrMessage(`Enter a month less than or equal to ${maxMonths}
|
|
4379
|
+
return sendErrMessage(`Enter a month less than or equal to ${maxMonths}`, {
|
|
4380
|
+
id: ValidationErrorId.expirationMaxMonth,
|
|
4381
|
+
maxMonth: maxMonths,
|
|
4382
|
+
});
|
|
4250
4383
|
}
|
|
4251
4384
|
if (!twoDigitsRegex.test(year)) {
|
|
4252
|
-
return sendErrMessage(
|
|
4385
|
+
return sendErrMessage('Enter a valid expiration year', {
|
|
4386
|
+
id: ValidationErrorId.expirationYearPattern,
|
|
4387
|
+
});
|
|
4253
4388
|
}
|
|
4254
4389
|
if (Number(year) < minYear) {
|
|
4255
|
-
return sendErrMessage(`Enter a year greater than or equal to ${minYear}
|
|
4390
|
+
return sendErrMessage(`Enter a year greater than or equal to ${minYear}`, {
|
|
4391
|
+
id: ValidationErrorId.expirationMinYear,
|
|
4392
|
+
minYear,
|
|
4393
|
+
});
|
|
4256
4394
|
}
|
|
4257
4395
|
const maxValidYear = minYear + maxYearsCount;
|
|
4258
4396
|
if (Number(year) > maxValidYear) {
|
|
4259
|
-
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}
|
|
4397
|
+
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}`, {
|
|
4398
|
+
id: ValidationErrorId.expirationMaxYear,
|
|
4399
|
+
maxYear: maxValidYear,
|
|
4400
|
+
});
|
|
4260
4401
|
}
|
|
4261
4402
|
return null;
|
|
4262
4403
|
}
|
|
@@ -8157,14 +8298,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8157
8298
|
class ValidatorsModule {
|
|
8158
8299
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ValidatorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
8159
8300
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: ValidatorsModule, imports: [CommonModule] }); }
|
|
8160
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ValidatorsModule, providers: [CreditCardMinLengthValidator], imports: [CommonModule] }); }
|
|
8301
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ValidatorsModule, providers: [CreditCardMinLengthValidator, CreditCardMaxLengthValidator], imports: [CommonModule] }); }
|
|
8161
8302
|
}
|
|
8162
8303
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ValidatorsModule, decorators: [{
|
|
8163
8304
|
type: NgModule,
|
|
8164
8305
|
args: [{
|
|
8165
8306
|
declarations: [],
|
|
8166
8307
|
imports: [CommonModule],
|
|
8167
|
-
providers: [CreditCardMinLengthValidator],
|
|
8308
|
+
providers: [CreditCardMinLengthValidator, CreditCardMaxLengthValidator],
|
|
8168
8309
|
}]
|
|
8169
8310
|
}] });
|
|
8170
8311
|
|