Skip to content

Commit

Permalink
Merge branch 'release/0.2.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
mmjmanders committed Sep 17, 2014
2 parents eb94b3f + 2f7a364 commit 3486a47
Show file tree
Hide file tree
Showing 5 changed files with 485 additions and 155 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-iban",
"version": "0.2.5",
"version": "0.2.6",
"authors": [
"Mark Manders <[email protected]>"
],
Expand Down
350 changes: 274 additions & 76 deletions dist/ng-iban.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,270 @@
var __modulo = function(a, b) { return (a % b + +b) % b; };

angular.module('mm.iban', ['ng']).constant('ngIbanCountries', {
AL: /^AL[0-9]{2}[0-9]{8}[A-Z0-9]{16}$/,
AD: /^AD[0-9]{2}[0-9]{4}[0-9]{4}[A-Z0-9]{12}$/,
AT: /^AT[0-9]{2}[0-9]{5}[0-9]{11}$/,
AZ: /^AZ[0-9]{2}[A-Z]{4}[A-Z0-9]{20}$/,
BH: /^BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}$/,
BE: /^BE[0-9]{2}[0-9]{3}[0-9]{7}[0-9]{2}$/,
BA: /^BA[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{8}[0-9]{2}$/,
BR: /^BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z]{1}[A-Z0-9]{1}$/,
BG: /^BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}$/,
CR: /^CR[0-9]{2}[0-9]{3}[0-9]{14}$/,
HR: /^HR[0-9]{2}[0-9]{7}[0-9]{10}$/,
CY: /^CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}$/,
CZ: /^CZ[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}$/,
DK: /^DK[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}$/,
DO: /^DO[0-9]{2}[A-Z0-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]{2}$/,
TN: /^TN[0-9]{2}[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}$/,
TR: /^TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}$/,
AE: /^AE[0-9]{2}[0-9]{3}[0-9]{16}$/,
GB: /^GB[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}$/,
VG: /^VG[0-9]{2}[A-Z]{4}[0-9]{16}$/
AL: {
name: 'Albania',
regex: /^AL[0-9]{2}[0-9]{8}[A-Z0-9]{16}$/
},
AD: {
name: 'Andorra',
regex: /^AD[0-9]{2}[0-9]{4}[0-9]{4}[A-Z0-9]{12}$/
},
AT: {
name: 'Austria',
regex: /^AT[0-9]{2}[0-9]{5}[0-9]{11}$/
},
AZ: {
name: 'Azerbaijan, Republic of',
regex: /^AZ[0-9]{2}[A-Z]{4}[A-Z0-9]{20}$/
},
BH: {
name: 'Bahrain',
regex: /^BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}$/
},
BE: {
name: 'Belgium',
regex: /^BE[0-9]{2}[0-9]{3}[0-9]{7}[0-9]{2}$/
},
BA: {
name: 'Bosnia and Herzegovina',
regex: /^BA[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{8}[0-9]{2}$/
},
BR: {
name: 'Brazil',
regex: /^BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z]{1}[A-Z0-9]{1}$/
},
BG: {
name: 'Bulgaria',
regex: /^BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}$/
},
CR: {
name: 'Costa Rica',
regex: /^CR[0-9]{2}[0-9]{3}[0-9]{14}$/
},
HR: {
name: 'Croatia',
regex: /^HR[0-9]{2}[0-9]{7}[0-9]{10}$/
},
CY: {
name: 'Cyprus',
regex: /^CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}$/
},
CZ: {
name: 'Czech Republic',
regex: /^CZ[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}$/
},
DK: {
name: 'Denmark',
regex: /^DK[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}$/
},
DO: {
name: 'Dominican Republic',
regex: /^DO[0-9]{2}[A-Z0-9]{4}[0-9]{20}$/
},
EE: {
name: 'Estonia',
regex: /^EE[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{11}[0-9]{1}$/
},
FO: {
name: 'Faroe Islands',
regex: /^FO[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}$/
},
FI: {
name: 'Finland',
regex: /^FI[0-9]{2}[0-9]{6}[0-9]{7}[0-9]{1}$/
},
FR: {
name: 'France',
regex: /^FR[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}$/
},
GE: {
name: 'Georgia',
regex: /^GE[0-9]{2}[A-Z]{2}[0-9]{16}$/
},
DE: {
name: 'Germany',
regex: /^DE[0-9]{2}[0-9]{8}[0-9]{10}$/
},
GI: {
name: 'Gibraltar',
regex: /^GI[0-9]{2}[A-Z]{4}[A-Z0-9]{15}$/
},
GR: {
name: 'Greece',
regex: /^GR[0-9]{2}[0-9]{3}[0-9]{4}[A-Z0-9]{16}$/
},
GL: {
name: 'Greenland',
regex: /^GL[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}$/
},
GT: {
name: 'Guatemala',
regex: /^GT[0-9]{2}[A-Z0-9]{4}[A-Z0-9]{20}$/
},
HU: {
name: 'Hungary',
regex: /^HU[0-9]{2}[0-9]{3}[0-9]{4}[0-9]{1}[0-9]{15}[0-9]{1}$/
},
IS: {
name: 'Iceland',
regex: /^IS[0-9]{2}[0-9]{4}[0-9]{2}[0-9]{6}[0-9]{10}$/
},
IE: {
name: 'Ireland',
regex: /^IE[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}$/
},
IL: {
name: 'Israel',
regex: /^IL[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{13}$/
},
IT: {
name: 'Italy',
regex: /^IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}$/
},
KZ: {
name: 'Kazakhstan',
regex: /^KZ[0-9]{2}[0-9]{3}[A-Z0-9]{13}$/
},
KW: {
name: 'Kuwait',
regex: /^KW[0-9]{2}[A-Z]{4}[A-Z0-9]{22}$/
},
LV: {
name: 'Latvia',
regex: /^LV[0-9]{2}[A-Z]{4}[A-Z0-9]{13}$/
},
LB: {
name: 'Lebanon',
regex: /^LB[0-9]{2}[0-9]{4}[A-Z0-9]{20}$/
},
LI: {
name: 'Liechtenstein (Principality of)',
regex: /^LI[0-9]{2}[0-9]{5}[A-Z0-9]{12}$/
},
LT: {
name: 'Lithuania',
regex: /^LT[0-9]{2}[0-9]{5}[0-9]{11}$/
},
LU: {
name: 'Luxembourg',
regex: /^LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}$/
},
MK: {
name: 'Macedonia',
regex: /^MK[0-9]{2}[0-9]{3}[A-Z0-9]{10}[0-9]{2}$/
},
MT: {
name: 'Malta',
regex: /^MT[0-9]{2}[A-Z]{4}[0-9]{5}[A-Z0-9]{18}$/
},
MR: {
name: 'Mauritania',
regex: /^MR[0-9]{2}[0-9]{5}[0-9]{5}[0-9]{11}[0-9]{2}$/
},
MU: {
name: 'Mauritius',
regex: /^MU[0-9]{2}[A-Z]{4}[0-9]{2}[0-9]{2}[0-9]{12}[0-9]{3}[A-Z]{3}$/
},
MD: {
name: 'Moldova, Republic of',
regex: /^MD[0-9]{2}[A-Z0-9]{20}$/
},
MC: {
name: 'Monaco',
regex: /^MC[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}$/
},
ME: {
name: 'Montenegro',
regex: /^ME[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}$/
},
NL: {
name: 'Netherlands',
regex: /^NL[0-9]{2}[A-Z]{4}[0-9]{10}$/
},
NO: {
name: 'Norway',
regex: /^NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}$/
},
PK: {
name: 'Pakistan',
regex: /^PK[0-9]{2}[A-Z]{4}[A-Z0-9]{16}$/
},
PL: {
name: 'Poland',
regex: /^PL[0-9]{2}[0-9]{8}[0-9]{16}$/
},
PS: {
name: 'Palestinian Territory, Occupied',
regex: /^PS[0-9]{2}[A-Z]{4}[A-Z0-9]{21}$/
},
PT: {
name: 'Portugal',
regex: /^PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}$/
},
QA: {
name: 'Qatar',
regex: /^QA[0-9]{2}[A-Z]{4}[A-Z0-9]{21}$/
},
RO: {
name: 'Romania',
regex: /^RO[0-9]{2}[A-Z]{4}[A-Z0-9]{16}$/
},
SM: {
name: 'San Marino',
regex: /^SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}$/
},
SA: {
name: 'Saudi Arabia',
regex: /^SA[0-9]{2}[0-9]{2}[A-Z0-9]{18}$/
},
RS: {
name: 'Serbia',
regex: /^RS[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}$/
},
SK: {
name: 'Slovak Republic',
regex: /^SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}$/
},
SI: {
name: 'Slovenia',
regex: /^SI[0-9]{2}[0-9]{5}[0-9]{8}[0-9]{2}$/
},
ES: {
name: 'Spain',
regex: /^ES[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{1}[0-9]{1}[0-9]{10}$/
},
SE: {
name: 'Sweden',
regex: /^SE[0-9]{2}[0-9]{3}[0-9]{16}[0-9]{1}$/
},
CH: {
name: 'Switzerland',
regex: /^CH[0-9]{2}[0-9]{5}[A-Z0-9]{12}$/
},
TL: {
name: 'Timor-Leste',
regex: /^TL[0-9]{2}[0-9]{3}[0-9]{14}[0-9]{2}$/
},
TN: {
name: 'Tunisia',
regex: /^TN[0-9]{2}[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}$/
},
TR: {
name: 'Turkey',
regex: /^TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}$/
},
AE: {
name: 'United Arab Emirates',
regex: /^AE[0-9]{2}[0-9]{3}[0-9]{16}$/
},
GB: {
name: 'United Kingdom',
regex: /^GB[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}$/
},
VG: {
name: 'Virgin Islands, British',
regex: /^VG[0-9]{2}[A-Z]{4}[0-9]{16}$/
}
}).directive('ngIban', ["ngIbanCountries", function(ngIbanCountries) {
return {
restrict: 'A',
Expand All @@ -90,7 +288,7 @@
A = 'A'.charCodeAt(0);
Z = 'Z'.charCodeAt(0);
iban = parseIban(value);
if (attrs.ngIban !== '' && (!!!(attrs.ngIban in ngIbanCountries) || !ngIbanCountries[attrs.ngIban].test(iban))) {
if (attrs.ngIban !== '' && (!!!(attrs.ngIban in ngIbanCountries) || !ngIbanCountries[attrs.ngIban].regex.test(iban))) {
return false;
}
iban = iban.substr(4) + iban.substr(0, 4);
Expand All @@ -109,13 +307,13 @@
}
return __modulo(parseInt(remainder, 10), 97) === 1;
};
ctrl.$parsers.unshift(function(value) {
ctrl.$parsers.unshift(function(viewValue) {
var parsed, valid;
valid = isValidIban(value);
valid = isValidIban(viewValue);
ctrl.$setValidity('iban', valid);
if (valid) {
parsed = parseIban(value);
if (parsed !== value) {
parsed = parseIban(viewValue);
if (parsed !== viewValue) {
ctrl.$setViewValue(parsed);
ctrl.$render();
}
Expand All @@ -124,18 +322,18 @@
return void 0;
}
});
return ctrl.$formatters.unshift(function(value) {
return ctrl.$formatters.unshift(function(modelValue) {
var parsed, valid;
valid = isValidIban(value);
valid = isValidIban(modelValue);
ctrl.$setValidity('iban', valid);
if (valid) {
parsed = parseIban(value);
if (parsed !== value) {
parsed = parseIban(modelValue);
if (parsed !== modelValue) {
scope[attrs.ngModel] = parsed;
}
return parsed;
} else {
return value;
return modelValue;
}
});
}
Expand Down
Loading

0 comments on commit 3486a47

Please sign in to comment.