Skip to content

RC7770/CreditCardValidator

 
 

Repository files navigation

Credit Card Validator on Swift

Credit Card Validator and type detector on Swift.

Inspired from https://github.com/MaxKramer/ObjectiveLuhn

Installation

pod "CreditCardValidator"

Usage

Validating

let number = "1234 5678 9123 4567"
   
let v = CreditCardValidator()
   
if v.validateString(number) {
  // Card number is valid
} else {
  // Card number is invalid
}

Detect Card Type

let number = "1234 5678 9123 4567"
   
let v = CreditCardValidator()
if let type = v.typeFromString(number) {
	println(type.name) // Visa, Mastercard, Amex etc.
} else {
	// I Can't detect type of credit card
}

Contribution

Contributions are very welcomed 👍😃.

About

Credit Card Validator in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.5%
  • Ruby 5.5%