Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getCreditCardType( number ) {
if ( number ) {
number = number.replace( / /g, '' );
let cardType = creditcards.card.type( number, true );
if ( typeof cardType === 'undefined' ) {
return null;
}
// We already use 'amex' for American Express everywhere else
if ( cardType === 'American Express' ) {
cardType = 'amex';
}
// Normalize Diners as well
if ( cardType === 'Diners Club' ) {
cardType = 'diners';
}
return cardType.toLowerCase();
export function getCreditCardType( number ) {
if ( number ) {
number = number.replace( / /g, '' );
let cardType = creditcards.card.type( number, true );
if ( typeof cardType === 'undefined' ) {
return null;
}
// We already use 'amex' for American Express everywhere else
if ( cardType === 'American Express' ) {
cardType = 'amex';
}
// Normalize Diners as well
if ( cardType === 'Diners Club' ) {
cardType = 'diners';
}
return cardType.toLowerCase();
isValid( value ) {
if ( ! value ) {
return false;
}
return creditcards.card.isValid( value );
},
error: validationError,
isValid( value ) {
if ( ! value ) {
return false;
}
return creditcards.card.isValid( value );
},
error: validationError,
'use strict'
var card = require('creditcards').card
var array = require('cast-array')
var partial = require('ap').partial
module.exports = factory
factory.$inject = ['$parse', '$timeout']
function factory ($parse, $timeout) {
return {
restrict: 'A',
require: ['ngModel', 'ccNumber'],
controller: function () {
this.type = null
this.eagerType = null
},
compile: function ($element, $attributes) {
$attributes.$set('pattern', '[0-9]*')