Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
var cvc = require('creditcards').cvc
var bind = require('function-bind')
module.exports = factory
factory.$inject = ['$parse']
function factory ($parse) {
return {
restrict: 'A',
require: 'ngModel',
compile: function (element, attributes) {
attributes.$set('maxlength', 4)
attributes.$set('pattern', '[0-9]*')
attributes.$set('xAutocompletetype', 'cc-csc')
return function (scope, element, attributes, ngModel) {
ngModel.$validators.ccCvc = function (value) {
isValid( value ) {
if ( ! value ) {
return false;
}
return creditcards.cvc.isValid( value );
},
error: validationError,
isValid( value ) {
if ( ! value ) {
return false;
}
return creditcards.cvc.isValid( value );
},
error: validationError,