// https://jqueryvalidation.org/documentation/
// Remote validation ??
// mime-types / extensions

// https://www.npmjs.com/package/validator
ISSN?
ISIN?
isJSON?

ip/mac address?

string (or format): isAlpha, isAlphaNum, isLowercase, isUpperCase, contains/include,
data-uri?
isColor?

// http://rickharrison.github.io/validate.js/validate.js


Valid file extension!
Valid mime type?!


number: hex option? step option (-> multiple of number entered)?

valid ip?
ipRegex = /^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i,

numericDashRegex = /^[\d\-\s]+$/,

valid_credit_card: function(field){
    // Luhn Check Code from https://gist.github.com/4075533
    // accept only digits, dashes or spaces
    if (!numericDashRegex.test(field.value)) return false;

    // The Luhn Algorithm. It's so pretty.
    var nCheck = 0, nDigit = 0, bEven = false;
    var strippedField = field.value.replace(/\D/g, "");

    for (var n = strippedField.length - 1; n >= 0; n--) {
        var cDigit = strippedField.charAt(n);
        nDigit = parseInt(cDigit, 10);
        if (bEven) {
            if ((nDigit *= 2) > 9) nDigit -= 9;
        }

        nCheck += nDigit;
        bEven = !bEven;
    }

    return (nCheck % 10) === 0;
},

is_file_type: function(field,type) {
    if (field.type !== 'file') {
        return true;
    }

    var ext = field.value.substr((field.value.lastIndexOf('.') + 1)),
        typeArray = type.split(','),
        inArray = false,
        i = 0,
        len = typeArray.length;

    for (i; i < len; i++) {
        if (ext.toUpperCase() == typeArray[i].toUpperCase()) inArray = true;
    }

    return inArray;
}



// DEFAULT_OPTIONS => defaultOptions
// validators.defaultOptions
// validators.messages
// validators.formatMessages => defaultOption?


// Doc: defaultOptions, messages, formatMessage (react-intl integration), REG_EMAIL, REG_URL, formatDate, parseDate
// Annoncer les changements de la version 2:
- plus dependant de react-intl, du coup need to define formatMessage + config babel
- defaultOptions

