@thecb/components 6.1.3 → 6.1.4-beta.3

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/dist/index.cjs.js CHANGED
@@ -34730,6 +34730,24 @@ const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
34730
34730
  const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
34731
34731
  validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
34732
34732
 
34733
+ /*
34734
+ 07/22: experimental expiration date constraint
34735
+ should allow entry of expiration date using "/" character
34736
+ to accommodate browser autofill
34737
+
34738
+ not tested as validation function
34739
+ to validate exp date instead use combo of:
34740
+ required(), hasLength(), isValidMonth(), dateAfterToday()
34741
+ */
34742
+ const ONLY_EXPIRATION_DATE = "validator/ONLY_EXPIRATION_DATE";
34743
+ const ONLY_EXPIRATION_DATE_ERROR = "error/ONLY_EXPIRATION_DATE";
34744
+ const onlyExpirationDate = createValidator(
34745
+ ONLY_EXPIRATION_DATE,
34746
+ ONLY_EXPIRATION_DATE_ERROR
34747
+ );
34748
+ validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
34749
+ /^(\d?\d?\/?\d?\d?)?$/.test(value);
34750
+
34733
34751
  const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
34734
34752
  const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
34735
34753
  const numberLessThan = createValidator(
@@ -35118,10 +35136,24 @@ const runValidator = (validator, value, form) => {
35118
35136
  if (validatorFn === undefined) {
35119
35137
  throw new Error(runValidatorErrorMessage(validator.type));
35120
35138
  }
35139
+ console.log(
35140
+ "run validator (validator, value, form):",
35141
+ validator.type,
35142
+ validator.args,
35143
+ value,
35144
+ form
35145
+ );
35121
35146
  return validatorFn(value, validator.args, form) ? null : validator.error;
35122
35147
  };
35123
35148
 
35124
35149
  const _computeErrors = (fieldName, form, validators) => {
35150
+ console.log("field name is", fieldName);
35151
+ console.log("form is", form);
35152
+ console.log("validators are", validators);
35153
+ const validatorsResult = validators.map(v =>
35154
+ runValidator(v, form[fieldName].rawValue, form)
35155
+ );
35156
+ console.log("validators result is", validatorsResult);
35125
35157
  return validators
35126
35158
  .map(v => runValidator(v, form[fieldName].rawValue, form))
35127
35159
  .filter(x => x !== null);
@@ -42299,7 +42331,7 @@ var formConfig$8 = {
42299
42331
  },
42300
42332
  expirationDate: {
42301
42333
  validators: [required(), hasLength(4, 4), isValidMonth(0), dateAfterToday("MMYY", "month", true)],
42302
- constraints: [onlyIntegers(), hasLength(0, 4)]
42334
+ constraints: [onlyExpirationDate(), hasLength(0, 4)]
42303
42335
  },
42304
42336
  cvv: {
42305
42337
  validators: [required(), hasLength(3, 4)],