Skip to content
This repository has been archived by the owner on Oct 19, 2019. It is now read-only.

azdanov/haskell-card-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haskell Card Validator

Build Status

Validate a card number. The algorithm follows these steps:

  • Double the value of every second digit beginning with the rightmost.
  • Add the digits of the doubled values and the undoubled digits from the original number.
  • Calculate the modulus of the sum divided by 10.

If the result equals 0, then the number is valid.

Setup

This project uses stack. You can read a Quick Start Guide for basic information.

git clone git@github.com:azdanov/haskell-card-validator.git
cd haskell-card-validator
stack setup
stack build

Usage

Stack provides a mechanism to run a built executable:

stack exec card-exe

Enter a Card Number:
4556945538735694
Number 4556945538735694 is invalid.


stack exec card-exe

Enter a Card Number:
5256283618614517
Number 5256283618614517 is valid.

Testing

Hspec is used for testing. To run the testing suite execute:

stack test

License

MIT

Releases

No releases published

Packages

No packages published