feat(isLuhnValid): Expose isLuhnValid independently from isCreditCard by ST-DDT · Pull Request #1974 · validatorjs/validator.js

Currently the luhn checking algorithm is only used inside isCreditCard, but the luhn algorithm is also used in/for other "numbers", so it would be nice if the isLuhnValid could be exposed independently.

is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the United States, Canadian Social Insurance Numbers, Israeli ID Numbers, South African ID Numbers, Swedish National identification numbers, Swedish Corporate Identity Numbers (OrgNr), Greek Social Security Numbers (ΑΜΚΑ), SIM card numbers and survey codes appearing on McDonald's, Taco Bell, and Tractor Supply Co. receipts.

Source: https://en.wikipedia.org/wiki/Luhn_algorithm

The code is copied from the existing isCreditCard check.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable) - Tests from isCreditCard apply, if any exist.