Multiform Validator
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Credit Card Validator

The CreditCardValidator class is used to validate credit card numbers. It has two methods, isCreditCardValid and identifyCreditCard.

How to use

isCreditCardValid

import io.github.multiform_validator.CreditCardValidator;

public class Main {
    public static void main(String[] args) {
        valid();
        invalid();
    }
    
    private static void valid() {
        System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4166")); // true
    }
    
    private static void invalid() {
        System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4167")); // false
    }
}

identifyCreditCard

import io.github.multiform_validator.CreditCardValidator;

public class Main {
    public static void main(String[] args) {
        String creditCard = "4532 8770 0040 4166";
        System.out.println(CreditCardValidator.identifyCreditCard(creditCard)); // Visa
    }
}

Other classes validation methods