flutter cardidy
a plugin to validate or identify card numbers & cvv with ease.
this flutter package will help you validate card numbers or cvvs and identiy card issuing provider with minimal code and efforts.
- simple and easy
- regex-free
- up-to-date with wikipedia
- no other dependencies
- well documented
- production-ready
cardidy written in c#.
this package is a flutter port of original packagenote: the closer we are to an official spec is the wikipedia’s payment card number page.
installation
dependencies:
flutter_cardidy: ^1.0.0
getting started
add the dependency to your project and start using flutter cardidy everywhere:
import the package.
import 'package:flutter_cardidy/flutter_cardidy.dart';
to validate and identify card’s issuing provider
// single card number identification
final result = fluttercardidy.identify("4127540509730813");
console.writeline(result.first); // print visa
multi card identification
// returns a kvp map of, cardnum as key & result as value
final mapresult = fluttercardidy.identifymultiple(["4127540509730813","4771320594031"]);
validating cvv
var cvv = "123";
var visacvvisvalid = fluttercardidy.iscvvvalid(cvv, cardtype.visa);
validating card number without identification
var iscardvalid = fluttercardidy.iscardnumbervalid("47!z320594033");
properties
return type of
identify
islist<cardtype>
. a card is sometimes a co-branded card like visa or visa electron, in this case all matching providers are returned.
property | type | default | note |
---|---|---|---|
cardnumstring (required) | string | – | your card number input string |
validatelength | bool | true | validate the length as part of the string identification. a false value can be useful to identify the fragment of a card number. |
ignorenoise | bool | false | ignore common noise found in card number. this noise is any of - . . |
handleanonymization | bool | false | set any non-digits to zero. it is common to use “x” and “#” to hide some digits. |
improve
help me by reporting bugs, submit new ideas for features or anything else that you want to share.
- just write an issue on github. ✏️
- and don’t forget to hit the like button for this package ✌️
more
check out my other useful packages on pub.dev
Comments are closed.