Skip to content

Commit

Permalink
Adding GAPS feature to show card number delimiters
Browse files Browse the repository at this point in the history
1. Gaps will be available as `gaps` in output
2. Adding `sodexo` support
3. Cleaning up and publishing new version
  • Loading branch information
boazjohn committed Aug 8, 2018
1 parent e3c65a4 commit a0705e8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,26 @@ This would output, card brand and different validation outputs like below:
valid: true,
luhn_valid: true,
length_valid: true,
cvv_length: [ 3 ] }
cvv_length: [ 3 ],
gaps: [ 4, 8, 12 ],
supported_lengths: [ 16 ],
max_length: 16 }
```

#### Output format

| Field | Description | Type |
| ----------------- | ------------------------------------- | ----------------- |
| card_type | The card issuer for the provided card | String |
| valid | Are the card details valid | Boolean |
| luhn_valid | Is the card number valid | Boolean |
| length_valid | If the card number length is valid | Boolean |
| cvv_length | If the CVV/CAVV length is valid | Array [ Integer ] |
| gaps | Gaps for UI as printed in cards | Array [ Integer ] |
| supported_lengths | Supported lengths for the card type | Array [ Integer ] |
| max_length | Maximum length for the card type | Integer |


### Validations
To simply validate a card, call:
`card.validateCard();`
Expand All @@ -45,10 +63,10 @@ CVV will be validated based on the brand of the card.

## Contribution

Read through the development
Read through the development
[guidelines](https://sites.google.com/a/juspay.in/card-validator-devel-guide/).

## License

MIT license. Copyright © 2016 - [juspay.in](https://www.juspay.in).
MIT license. Copyright © 2018 - [juspay.in](https://www.juspay.in).

12 changes: 6 additions & 6 deletions dist/validator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": " @juspay/simple-card-validator",
"version": "1.1.0",
"version": "1.2.0",
"description": "Card validation helpers for card number, expiry and CVV.",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ var cardTypes = [
valid_length: [16],
cvv_length: [3],
gaps: [4, 8, 12],
}
},
{
type: 'sodexo',
pattern: /^(637513)/,
length: [16],
cvcLength: [3],
gaps: [4, 8, 12]
}
];

/**
Expand Down

0 comments on commit a0705e8

Please sign in to comment.