Git Product home page Git Product logo

simple-card's Introduction

npm David David Travis Coverage Status

Simple Card

A simple credit card system that runs validation for credit cards it uses a luhn algorithm for number validation and has a solid array of numbers to find and validate card types against.

Changelog

You can view the changelog here: https://github.com/dhershman1/simple-card/blob/master/changelog.md

How To

Simple Card is a plug and play module, import, require, or even script tag it in

Standard JS

import { validate } from 'simple-card';

validate(data);

CommonJS

const { validate } = require('simple-card');

validate(data);

Browser

<script src="/path/to/simple-card.min.js"></script>
<script>
	simpleCard.validate(data);
</script>

Documentation

You can find most of the documentation for simple card here: https://www.dusty.codes/simple-card

Modular

Simple Card is completely modular which means each piece of functionality can be imported by itself directly, or with destructuring.

Example:

import validate from 'simple-card/validate'
import num from 'simple-card/number'
import cvn from 'simple-card/cvn'
import expired from 'simple-card/expired'
import matches from 'simple-card/matches'

// Or with destructuring

import { validate, number, cvn, matches, expired } from 'simple-card'

You can then call each function individually.

This also works with commonjs you just need to point directly to the file you want

NOTE: In order to use validate you need to pass a full card object to it like so:

{
  number: '4111 1111 1111 1111',
  cvn: '342',
  date: '12/20'
}

simple-card's People

Contributors

dhershman1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

simple-card's Issues

Remove support for passing main method a single string

With the functionality of #1 we will want to remove sending a single string value to the main function to help make the code base less convoluted and easier to follow

So this example would no longer be valid:

import simpleCard from 'simple-card';

simpleCard('4111111111111111');
simpleCard('333');
simpleCard('09/10');

In favor of calling the individual methods that would be brought on by #1

Better Organization

Hopefully with the introduction of #1 and #2 we can see an improvement to code organization and a less complex code base.

However I don't want to stop there, primarily I want to finish moving internals around if they are only being used in a single spot (then whats the point in having them be in a different file?)

As well as making the code easier to sift through and understand if you want to view the source code.

Drop partial Object support

Like single string support (#2) I would probably like to remove the partial object support, because it might get in the way and create unwarrented overhead when the module is being used.

I would like to remove any overhead for finding the card type to make it as accurate as I can. As well as making the code as maintainable as I can for 2.0.0

Make each validation method callable by itself

The plan is to allow users to bring in and call validation methods they need/want

Example:
How it currently works

import simpleCard from 'simple-card';

simpleCard('4111111111111111'); // Validate single Card Number
simpleCard('333'); // Validate single CVN
simpleCard('1/20'); // Validate single date

Instead we should allow for:
Note The import from values are concepts/placeholders that may change on release

import validNumber from 'simple-card/number';
import validCVN from 'simple-card/cvn';
import validDate from 'simple-card/expire';

validNumber('4111111111111111');
validCVN('333');
validDate('1/20');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.