Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

card-validator

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

card-validator - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

4.1.0
=====
- Add options object for postal code validation to specify min length
4.0.0

@@ -2,0 +7,0 @@ =====

2

package.json
{
"name": "card-validator",
"version": "4.0.0",
"version": "4.1.0",
"description": "A library for validating credit card fields",

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

@@ -278,3 +278,3 @@ # Credit Card Validator [![Build Status](https://travis-ci.org/braintree/card-validator.svg)](https://travis-ci.org/braintree/card-validator) [![npm version](https://badge.fury.io/js/card-validator.svg)](http://badge.fury.io/js/card-validator)

#### `valid.postalCode(value: string): object`
#### `valid.postalCode(value: string, [options: object]): object`

@@ -290,2 +290,13 @@ The `postalCode` validation essentially tests for a valid string greater than 3 characters in length.

You can optionally pass `minLength` as a property of an object as a second argument. This will override the default min length of 3.
```javascript
valid.postalCode('123', {minLength: 5});
{
isPotentiallyValid: true,
isValid: false
}
```
## Design decisions

@@ -292,0 +303,0 @@

'use strict';
var MIN_POSTAL_CODE_LENGTH = 3;
var DEFAULT_MIN_POSTAL_CODE_LENGTH = 3;

@@ -9,6 +9,12 @@ function verification(isValid, isPotentiallyValid) {

function postalCode(value) {
function postalCode(value, options) {
var minLength;
options = options || {};
minLength = options.minLength || DEFAULT_MIN_POSTAL_CODE_LENGTH;
if (typeof value !== 'string') {
return verification(false, false);
} else if (value.length < MIN_POSTAL_CODE_LENGTH) {
} else if (value.length < minLength) {
return verification(false, true);

@@ -15,0 +21,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc