Skip to content

Instantly share code, notes, and snippets.

View johadtech's full-sized avatar

Jonathan Azuonye johadtech

View GitHub Profile
@johadtech
johadtech / card_utils.dart
Created July 3, 2024 11:34 — forked from wilburx9/card_utils.dart
Validating card number with Luhn algorithm in dart/flutter
static String validateCardNumWithLuhnAlgorithm(String input) {
if (input.isEmpty) {
return Strings.fieldReq;
}
input = getCleanedNumber(input);
if (input.length < 8) { // No need to even proceed with the validation if it's less than 8 characters
return Strings.numberIsInvalid;
}