@xsolla/payment-client-core 0.0.10-5 → 0.0.10

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.
@@ -967,9 +967,7 @@ class SyncService extends EmitDataService {
967
967
  return Promise.resolve(null);
968
968
  }
969
969
  if (prevFieldState && value === prevFieldState.value) {
970
- return Promise.resolve(prevFieldState.result).then((response) => {
971
- return response?.rewritableError ?? null;
972
- });
970
+ return Promise.resolve(prevFieldState.result);
973
971
  }
974
972
  const requestPromise = this.request(field);
975
973
  this.setPrevFieldSyncState(field, value, requestPromise);
@@ -977,14 +975,6 @@ class SyncService extends EmitDataService {
977
975
  return response.rewritableError ?? null;
978
976
  });
979
977
  }
980
- getSyncValidationErrors(field) {
981
- const control = this.form.get(field.name);
982
- if (!control) {
983
- return null;
984
- }
985
- const rewritableError = control.errors?.rewritableError;
986
- return rewritableError ? { message: rewritableError.message } : null;
987
- }
988
978
  async request(field) {
989
979
  const requestParams = this.requestFactory({
990
980
  token: this.settingsService.token,
@@ -1083,7 +1073,7 @@ class Converter {
1083
1073
  return config;
1084
1074
  }
1085
1075
  convertToFormControl(field) {
1086
- return new UntypedFormControl(this.getValue(field), this.getValidators(field));
1076
+ return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
1087
1077
  }
1088
1078
  getValidators(field) {
1089
1079
  const validators = [];
@@ -1102,6 +1092,9 @@ class Converter {
1102
1092
  }
1103
1093
  return validators;
1104
1094
  }
1095
+ getAsyncValidators(field) {
1096
+ return async () => this.syncService.validate(field);
1097
+ }
1105
1098
  createDefaultControlConfig(controlConfigClass, field) {
1106
1099
  const config = new controlConfigClass();
1107
1100
  this.copyCommonOptions(config, field);
@@ -1186,8 +1179,8 @@ class ZipConverter extends Converter {
1186
1179
  const validators = super
1187
1180
  .getValidators(field)
1188
1181
  .concat([
1189
- convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
1190
- convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`),
1182
+ convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
1183
+ convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
1191
1184
  ]);
1192
1185
  if (this.isUsCountry) {
1193
1186
  validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
@@ -1199,15 +1192,7 @@ class ZipConverter extends Converter {
1199
1192
  config.icon = 'location';
1200
1193
  if (this.isUsCountry) {
1201
1194
  config.maskConfig = {
1202
- // mask: () => new Array(this.usCountryLength).fill('9').join(''),
1203
- mask: () => new Array(5).fill('9').join(''),
1204
- // mask: function() { return new Array(5).fill('9').join('') },
1205
- // mask: function mask() {
1206
- // const length = this.usCountryLength;
1207
- // return function() {
1208
- // return new Array(length).fill('9').join('');
1209
- // }
1210
- // },
1195
+ mask: () => new Array(this.usCountryLength).fill('9').join(''),
1211
1196
  guide: false,
1212
1197
  unmaskModelValue: true,
1213
1198
  showMask: true,
@@ -2734,10 +2719,6 @@ class PaymentService {
2734
2719
  return this.data?.paymentForm?.fields ?? [];
2735
2720
  }
2736
2721
  async validate(field) {
2737
- const syncErrors = this.syncService.getSyncValidationErrors(field);
2738
- if (syncErrors) {
2739
- return Promise.resolve(syncErrors);
2740
- }
2741
2722
  return this.syncService.validate(field);
2742
2723
  }
2743
2724
  runThreeDs() {