Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Commit

Permalink
Documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dhershman committed Feb 22, 2018
1 parent 8f3eac5 commit 6136d55
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const badCardObj = {
number: '4111111111111111',
cvn: '3432',
date: currentDate // A simple var which is a string for the current date
}
};

validate(badCardObj); // => { isValid: false, cardType: 'visa', cvnType: 'norm', expired: 'Not Expired', info: 'CVN does not match the found card type' }

Expand Down
9 changes: 6 additions & 3 deletions src/cvn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ const getCvnType = cvn => {
* @return {Object} An object containing a isValid boolean and some info
*
* @example
* cvn('333'); // => { isValid: true, info: 'norm' }
* cvn('3333'); // => { isValid: true, info: 'amex' }
* cvn('33433'); // => { isValid: false, info: 'Invalid CVN Code' }
* cvn('333'); // => { isValid: true, cvnType: 'norm' }
* cvn(333); // => { isValid: true, cvnType: 'norm' }
* cvn('4444'); // => { isValid: true, cvnType: 'amex' }
* cvn(4444); // => { isValid: true, cvnType: 'amex' }
* cvn('55555'); // => { isValid: false, cvnType: 'Invalid CVN Code' }
* cvn(55555); // => { isValid: false, cvnType: 'Invalid CVN Code' }
*/
export default cvnCode => {
if (!typeCheck(cvnCode)) {
Expand Down
5 changes: 3 additions & 2 deletions src/expired/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ const normalizeDate = date => {
* @return {Object} An object containing a isValid boolean and some info
*
* @example
* expired('04/20'); // => { isValid: true, info: 'Not Expired' }
* expired('01/17'); // => { isValid: false, info: 'Is Expired' }
* // Assuming "currDate" is a variable that holds the current date in a XX/XX format
* expired(currDate); // => { isValid: true, isExpired: false }
* expired('01/18'); // => { isValid: false, isExpired: true }
*/
const expired = date => {
if (typeof date !== 'string') {
Expand Down
8 changes: 6 additions & 2 deletions src/matches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ const match = (cvn, type) => {
* @return {Boolean} A boolean based on if the match is valid or not
*
* @example
* matches('333', '4111111111111111'); // => true
* matches('4444', '4111111111111111'); // => false
* matches('333', '4111111111111111'); // => { isValid: true, match: 'card type matches cvn' }
* matches(333, 4111111111111111); // => { isValid: true, match: 'card type matches cvn' }
* matches('4444', amexCardNumber); // => { isValid: true, match: 'card type matches cvn' }
* matches(4444, amexCardNumber); // => { isValid: true, match: 'card type matches cvn' }
* matches('4444', '4111111111111111'); // => { isValid: false, match: 'cvn does not match card type' }
* matches(4444, 4111111111111111); // => { isValid: false, match: 'cvn does not match card type' }
*/
export default (cvn, card) => {
if (!typeCheck(cvn) || !typeCheck(card)) {
Expand Down
4 changes: 3 additions & 1 deletion src/number/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const luhnChk = value => { // eslint-disable-line complexity
*
* @example
* number('4111111111111111'); // => { isValid: true, cardType: 'visa' }
* number('4444'); // => { isValid: false, cardType: 'Invalid Card Number' }
* number(4111111111111111); // => { isValid: true, cardType: 'visa' }
* number('33222123'); // => { isValid: false, cardType: 'Invalid Card Number' }
* number(33222123); // => { isValid: false, cardType: 'Invalid Card Number' }
*/
const cNumber = card => {
if (!typeCheck(card)) {
Expand Down
8 changes: 7 additions & 1 deletion src/validate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ const validation = ({ number, cvn, date }) => {
* @returns {Object} Returns an object of information about the test and whether or not it passed
*
* @example
* const test = simpleCard({
* const test = validate({
number: '4111111111111111',
cvn: '333',
date: '09/20'
}); // => { isValid: true, cardType: 'visa', cvnType: 'norm', expired: false }
validate({
number: '4111111111111111',
cvn: '3432',
date: currentDate // A simple var which is a string for the current date
}); // => { isValid: false, cardType: 'visa', cvnType: 'norm', expired: 'Not Expired', info: 'CVN does not match the found card type' }
*/
const simpleCard = card => {
if (Object.prototype.toString.call(card) !== '[object Object]') {
Expand Down

0 comments on commit 6136d55

Please sign in to comment.