Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.text.TextUtils;

public class Main {
    private static final int PAN_LENGTH_MIN = 13;
    private static final int PAN_LENGTH_MAX = 19;

    public static boolean isValidCardNumber(String pan) {
        if (TextUtils.isEmpty(pan)) {
            return false;
        }

        if (pan.length() < PAN_LENGTH_MIN || pan.length() > PAN_LENGTH_MAX) {
            return false;
        }

        // check all numeric
        if (!TextUtils.isDigitsOnly(pan)) {
            return false;
        }

        return true;
    }
}