verygoodsecurity / vgs-collect-js

VGS Collect.js script loading module
https://www.verygoodsecurity.com/
7 stars 17 forks source link

Need validation for comparing 2 value must not be equal #58

Open ThuyTrang144 opened 1 year ago

ThuyTrang144 commented 1 year ago

Missing validation for compare 2 value must be different

compareValue(value, fieldProps, validationName, validationParams, globalValue) {
    const { field, function: fn } = validationParams;
    const valueToCompare = globalValue[field];

    const allowed = {
      match: () => valueToCompare === value,
      notMatch: () => valueToCompare !== value,
    };

    if (!Object.hasOwnProperty.call(allowed, fn)) {
      throw new CollectError(
        `compareValue function "${fn}" does not exist. Allowed: ${Object.keys(allowed).join(', ')}`
      );
    }
    return allowed[fn]();
  },

I want to update one more validation for 2 value must be not equal. Please help me to check a look and this. Thank you!