Sha256: 6fa36521a4a7a29a87a755b0d6977ae00ef90d693f5058a7cc4c81485988f0b0

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

/*!
* Parsley-Payment.js
* Version 1.0.0
* http://github.com/cmer/parsley-payment
* Carl Mercier - <carl@carlmercier.com>
* MIT Licensed
*/

(function () {
    'use strict';

    window.Parsley.addValidator('creditcard',
        function (value, requirement) {
            var valid = jQuery.payment.validateCardNumber(value);

            // Checks for specific brands
            if(valid && requirement.length){
                var valid_cards = requirement.split(','),
                    valid = false,
                    card = jQuery.payment.cardType(value);

                if(requirement.indexOf(card) > -1) {
                    valid = true;
                }
            }
            return valid;
        },32)
        .addMessage('en', 'creditcard', 'This credit card number is invalid or this brand is not supported.')
        .addMessage('fr', 'creditcard', 'Ce numéro de carte de crédit est invalide ou ce type de carte n\'est pas supporté');


    window.Parsley.addValidator('cvv',
        function (value) {
            var valid = jQuery.payment.validateCardCVC(value);
            return valid;
        }, 32)
        .addMessage('en', 'cvv', 'This value should be a valid CVV number')
        .addMessage('fr', 'cvv', 'Cette valeur doit être un code de vérification CVV valide');


    window.Parsley.addValidator('cardexpiry',
        function (value) {
            if(value.indexOf('/') === -1) {
                return false;
            }

            var date = $.payment.cardExpiryVal(value),
                month = date.month,
                year  = date.year;

            var valid = jQuery.payment.validateCardExpiry(month, year);
            return valid;
        }, 32)
        .addMessage('en', 'cardexpiry', 'This value should be a valid date')
        .addMessage('fr', 'cardexpiry', 'Cette valeur doit être une date valide');
}());

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parsley-payment-rails-1.0.0.0 vendor/assets/javascripts/parsley-payment.js