diff --git a/changelog.md b/changelog.md index 5c577c0..1af7510 100644 --- a/changelog.md +++ b/changelog.md @@ -4,8 +4,8 @@ #### Breaking Changes -- The ability to send single strings into the main function (call the individual functions) -- The ability to send partial objects to the main function +- Removed the ability to send single strings into the main function (call the individual functions) +- Removed the ability to send partial objects to the main function - Changed the expected card object property name from `expire` to `date` #### New @@ -15,7 +15,7 @@ - `expired` which can be used to validate a credit cards expiration date - `matches` which can be used to see if a cvn and a card number match (the cvn length matches the card type) - `validation` which is the core functionality and only accepts an object -- An info property to the results that says if it failed by a rule or if it failed matching +- A match property was added to the results that says if it failed by a rule or if it failed matching - Type Errors have been added when the correct type of value isn't provided (String or Number) - Converted to a webpack build along with automation scripts for docs, and building files - README has been updated with all the needed changes diff --git a/docs.js b/docs.js index e37d855..3db3217 100644 --- a/docs.js +++ b/docs.js @@ -1 +1 @@ -module.exports = [{"title":"cvn","since":"v2.0.0","syntax":"cvn(cvnCode)","usage":{"commonjs":{"title":"CommonJs","code":"const cvn = require('simple-card/cvn');"},"standard":{"title":"Standard","code":"import cvn from 'simple-card/cvn';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the string cvn passed in is a valid cvn number","examples":["cvn('333'); // => { isValid: true, info: 'norm' }\rcvn('3333'); // => { isValid: true, info: 'amex' }\rcvn('33433'); // => { isValid: false, info: 'Invalid CVN Code' }"],"params":[{"type":{"names":["String","Number"]},"description":"The string cvn we want to validate","name":"cvnCode"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"expired","since":"v2.0.0","syntax":"expired(date)","usage":{"commonjs":{"title":"CommonJs","code":"const expired = require('simple-card/expired');"},"standard":{"title":"Standard","code":"import expired from 'simple-card/expired';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the string date passed in is indeed a valid date and not an old one","examples":["expired('04/20'); // => { isValid: true, info: 'Not Expired' }\rexpired('01/17'); // => { isValid: false, info: 'Is Expired' }"],"params":[{"type":{"names":["String"]},"description":"The string date we want to validate","name":"date"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"matches","since":"v2.0.0","syntax":"matches(cvn, card)","usage":{"commonjs":{"title":"CommonJs","code":"const matches = require('simple-card/matches');"},"standard":{"title":"Standard","code":"import matches from 'simple-card/matches';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the card type (generated from the card number) matches and is valid with the cvn provided","examples":["matches('333', '4111111111111111'); // => true\rmatches('4444', '4111111111111111'); // => false"],"params":[{"type":{"names":["String","Number"]},"description":"The string cvn we want to validate","name":"cvn"},{"type":{"names":["String","Number"]},"description":"The string card we want to validate with","name":"card"}],"returns":[{"type":{"names":["Boolean"]},"description":"A boolean based on if the match is valid or not"}]},{"title":"number","since":"v2.0.0","syntax":"number(card)","usage":{"commonjs":{"title":"CommonJs","code":"const number = require('simple-card/number');"},"standard":{"title":"Standard","code":"import number from 'simple-card/number';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the card number is an actual valid number with a luhn algorithm. As well as finds the cards type","examples":["number('4111111111111111'); // => { isValid: true, cardType: 'visa' }\rnumber('4444'); // => { isValid: false, cardType: 'Invalid Card Number' }"],"params":[{"type":{"names":["String","Number"]},"description":"The string card we want to validate","name":"card"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"validate","since":"v2.0.0","syntax":"validate(card)","usage":{"commonjs":{"title":"CommonJs","code":"const validate = require('simple-card/validate');"},"standard":{"title":"Standard","code":"import validate from 'simple-card/validate';"},"browser":{"title":"Browser","code":""}},"desc":"Validates a credit card object comparing and validating each piece of data on the card passed in","examples":["const test = simpleCard({\n number: '4111111111111111',\n cvn: '333',\n date: '09/20'\n }); // => { isValid: true, cardType: 'visa', cvnType: 'norm', expired: false }"],"params":[{"type":{"names":["Object"]},"description":"The card Object that we wish to be validated","name":"card"}],"returns":[{"type":{"names":["Object"]},"description":"Returns an object of information about the test and whether or not it passed"}]}] \ No newline at end of file +module.exports = [{"title":"cvn","since":"v2.0.0","syntax":"cvn(cvnCode)","usage":{"commonjs":{"title":"CommonJs","code":"const cvn = require('simple-card/cvn');"},"standard":{"title":"Standard","code":"import cvn from 'simple-card/cvn';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the string cvn passed in is a valid cvn number","examples":["cvn('333'); // => { isValid: true, cvnType: 'norm' }\rcvn(333); // => { isValid: true, cvnType: 'norm' }\rcvn('4444'); // => { isValid: true, cvnType: 'amex' }\rcvn(4444); // => { isValid: true, cvnType: 'amex' }\rcvn('55555'); // => { isValid: false, cvnType: 'Invalid CVN Code' }\rcvn(55555); // => { isValid: false, cvnType: 'Invalid CVN Code' }"],"params":[{"type":{"names":["String","Number"]},"description":"The string cvn we want to validate","name":"cvnCode"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"expired","since":"v2.0.0","syntax":"expired(date)","usage":{"commonjs":{"title":"CommonJs","code":"const expired = require('simple-card/expired');"},"standard":{"title":"Standard","code":"import expired from 'simple-card/expired';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the string date passed in is indeed a valid date and not an old one","examples":["// Assuming \"currDate\" is a variable that holds the current date in a XX/XX format\rexpired(currDate); // => { isValid: true, isExpired: false }\rexpired('01/18'); // => { isValid: false, isExpired: true }"],"params":[{"type":{"names":["String"]},"description":"The string date we want to validate","name":"date"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"matches","since":"v2.0.0","syntax":"matches(cvn, card)","usage":{"commonjs":{"title":"CommonJs","code":"const matches = require('simple-card/matches');"},"standard":{"title":"Standard","code":"import matches from 'simple-card/matches';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the card type (generated from the card number) matches and is valid with the cvn provided","examples":["matches('333', '4111111111111111'); // => { isValid: true, match: 'card type matches cvn' }\rmatches(333, 4111111111111111); // => { isValid: true, match: 'card type matches cvn' }\rmatches('4444', amexCardNumber); // => { isValid: true, match: 'card type matches cvn' }\rmatches(4444, amexCardNumber); // => { isValid: true, match: 'card type matches cvn' }\rmatches('4444', '4111111111111111'); // => { isValid: false, match: 'cvn does not match card type' }\rmatches(4444, 4111111111111111); // => { isValid: false, match: 'cvn does not match card type' }"],"params":[{"type":{"names":["String","Number"]},"description":"The string cvn we want to validate","name":"cvn"},{"type":{"names":["String","Number"]},"description":"The string card we want to validate with","name":"card"}],"returns":[{"type":{"names":["Boolean"]},"description":"A boolean based on if the match is valid or not"}]},{"title":"number","since":"v2.0.0","syntax":"number(card)","usage":{"commonjs":{"title":"CommonJs","code":"const number = require('simple-card/number');"},"standard":{"title":"Standard","code":"import number from 'simple-card/number';"},"browser":{"title":"Browser","code":""}},"desc":"Validates that the card number is an actual valid number with a luhn algorithm. As well as finds the cards type","examples":["number('4111111111111111'); // => { isValid: true, cardType: 'visa' }\rnumber(4111111111111111); // => { isValid: true, cardType: 'visa' }\rnumber('33222123'); // => { isValid: false, cardType: 'Invalid Card Number' }\rnumber(33222123); // => { isValid: false, cardType: 'Invalid Card Number' }"],"params":[{"type":{"names":["String","Number"]},"description":"The string card we want to validate","name":"card"}],"returns":[{"type":{"names":["Object"]},"description":"An object containing a isValid boolean and some info"}]},{"title":"validate","since":"v2.0.0","syntax":"validate(card)","usage":{"commonjs":{"title":"CommonJs","code":"const validate = require('simple-card/validate');"},"standard":{"title":"Standard","code":"import validate from 'simple-card/validate';"},"browser":{"title":"Browser","code":""}},"desc":"Validates a credit card object comparing and validating each piece of data on the card passed in","examples":["const test = validate({\n number: '4111111111111111',\n cvn: '333',\n date: '09/20'\n }); // => { isValid: true, cardType: 'visa', cvnType: 'norm', expired: false }\n\n validate({\n number: '4111111111111111',\n cvn: '3432',\n date: currentDate // A simple var which is a string for the current date\n }); // => { isValid: false, cardType: 'visa', cvnType: 'norm', expired: 'Not Expired', info: 'CVN does not match the found card type' }"],"params":[{"type":{"names":["Object"]},"description":"The card Object that we wish to be validated","name":"card"}],"returns":[{"type":{"names":["Object"]},"description":"Returns an object of information about the test and whether or not it passed"}]}] \ No newline at end of file