How to use the text-mask-core.conformToMask function in text-mask-core

To help you get started, we’ve selected a few text-mask-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atanasster / grommet-nextjs / components / grommet / MaskedInput / utils.js View on Github external
}
  let conformedValue = value;
  const {
    guide, placeholderChar, placeholder, currentCaretPosition,
    showMask, keepCharPositions,
  } = props;

  const conformToMaskConfig = {
    previousPlaceholder: placeholder,
    guide,
    placeholderChar,
    pipe,
    currentCaretPosition,
    keepCharPositions,
  };
  const conformed = conformToMask(safeValue, mask, conformToMaskConfig);
  if (conformed) {
    ({ conformedValue } = conformed);
  }
  if (typeof pipe === 'function') {
    const pipeResults = pipe(conformedValue, { rawValue: safeValue, ...conformToMaskConfig });
    if (typeof pipeResults === 'string') {
      conformedValue = pipeResults;
    }
  }
  if (conformedValue === placeholder) {
    conformedValue = showMask ? placeholder : '';
  }
  return conformedValue;
};

text-mask-core

Core of https://github.com/text-mask/text-mask

Unlicense
Latest version published 6 years ago

Package Health Score

62 / 100
Full package analysis