Socket
Socket
Sign inDemoInstall

card-validator

Package Overview
Dependencies
1
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.0 to 9.1.0

1

dist/card-number.d.ts

@@ -19,4 +19,5 @@ import type { Verification } from "./types";

luhnValidateUnionPay?: boolean;
skipLuhnValidation?: boolean;
};
export declare function cardNumber(value: string | unknown, options?: CardNumberOptions): CardNumberVerification;
export {};

5

dist/card-number.js

@@ -34,4 +34,5 @@ "use strict";

}
if (cardType.type === getCardTypes.types.UNIONPAY &&
options.luhnValidateUnionPay !== true) {
if (options.skipLuhnValidation === true ||
(cardType.type === getCardTypes.types.UNIONPAY &&
options.luhnValidateUnionPay !== true)) {
isValid = true;

@@ -38,0 +39,0 @@ }

{
"name": "card-validator",
"version": "9.0.0",
"version": "9.1.0",
"description": "A library for validating credit card fields",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -79,2 +79,4 @@ # Credit Card Validator [![Build Status](https://github.com/braintree/card-validator/workflows/Unit%20Tests/badge.svg)](https://github.com/braintree/card-validator/actions?query=workflow%3A%22Unit+Tests%22) [![npm version](https://badge.fury.io/js/card-validator.svg)](http://badge.fury.io/js/card-validator)

You can optionally pass `skipLuhnValidation: true` as a property of an object as a second argument. This will override the default behaviour and will skip the validation of the check digit of the card number using Luhn Algorithm. The `skipLuhnValidation` **should not** be set to `true` in production environment.
```javascript

@@ -81,0 +83,0 @@ valid.number(<Maestro Card with 19 Digits>, {maxLength: 16});

@@ -352,2 +352,23 @@ import { cardNumber, CardNumberVerification } from "../card-number";

});
describe("Skip Luhn Validation", () => {
const number = "5732806135556590";
it("should fail validation for a card with invalid luhn check digit", () => {
const actual = cardNumber(number);
expect(actual.card.type).toBe("maestro");
expect(actual.isPotentiallyValid).toBe(true);
expect(actual.isValid).toBe(false);
});
it("should succeed validation for a card with invalid luhn check digit when using skipLuhnValidation=true", () => {
const actual = cardNumber(number, {
skipLuhnValidation: true,
});
expect(actual.card.type).toBe("maestro");
expect(actual.isPotentiallyValid).toBe(true);
expect(actual.isValid).toBe(true);
});
});
});

@@ -25,2 +25,3 @@ import luhn10 = require("./luhn-10");

luhnValidateUnionPay?: boolean;
skipLuhnValidation?: boolean;
};

@@ -71,4 +72,5 @@

if (
cardType.type === getCardTypes.types.UNIONPAY &&
options.luhnValidateUnionPay !== true
options.skipLuhnValidation === true ||
(cardType.type === getCardTypes.types.UNIONPAY &&
options.luhnValidateUnionPay !== true)
) {

@@ -75,0 +77,0 @@ isValid = true;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc