cre

CreditCardValidator

Credit Card Validator in Swift

Showing:

Popularity

Downloads/wk

0

GitHub Stars

107

Maintenance

Last Commit

5mos ago

Contributors

3

Package

Dependencies

0

License

MIT

Categories

Readme

Installation

CocoaPods

pod "CreditCardValidator", '~> 0.5.1'

Swift Package Manager

.package(url: "https://github.com/vitkuzmenko/CreditCardValidator.git", from: "0.5.0")

After specifying "CreditCardValidator" as a dependency of the target in which you want to use it, run swift package update.

Accio

Do the same configurations as for SwiftPM, then run accio update instead of swift package update.

Usage

Validating

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

Detect Card Type

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

Check type and validation

let number = "1234 5678 9123 4567"
   
if CreditCardValidator(number).isValid(for: .visa) {
    // Card number is valid and type is .visa
} else {
    // I Can't detect type of credit card
}

Supported types

  • Amex
  • Visa
  • MasterCard
  • Maestro
  • DinersClub
  • JCB
  • Discover
  • UnionPay
  • Mir

Contribution

Contributions are very welcomed 👍😃.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100