File tree 4 files changed +15
-5
lines changed
4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1
1
import assertString from './util/assertString' ;
2
+ import { CountryCodes } from './isISO31661Alpha2' ;
2
3
3
- const isBICReg = / ^ [ A - z ] { 4 } [ A - z ] { 2 } \w { 2 } ( \w { 3 } ) ? $ / ;
4
+ // https://en.wikipedia.org/wiki/ISO_9362
5
+ const isBICReg = / ^ [ A - Z a - z ] { 6 } [ A - Z a - z 0 - 9 ] { 2 } ( [ A - Z a - z 0 - 9 ] { 3 } ) ? $ / ;
4
6
5
7
export default function isBIC ( str ) {
6
8
assertString ( str ) ;
9
+
10
+ // toUpperCase() should be removed when a new major version goes out that changes
11
+ // the regex to [A-Z] (per the spec).
12
+ if ( CountryCodes . indexOf ( str . slice ( 4 , 6 ) . toUpperCase ( ) ) < 0 ) {
13
+ return false ;
14
+ }
15
+
7
16
return isBICReg . test ( str ) ;
8
17
}
Original file line number Diff line number Diff line change 1
1
import assertString from './util/assertString' ;
2
- import includes from './util/includes' ;
3
2
4
3
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
5
4
const validISO31661Alpha2CountriesCodes = [
@@ -32,5 +31,7 @@ const validISO31661Alpha2CountriesCodes = [
32
31
33
32
export default function isISO31661Alpha2 ( str ) {
34
33
assertString ( str ) ;
35
- return includes ( validISO31661Alpha2CountriesCodes , str . toUpperCase ( ) ) ;
34
+ return validISO31661Alpha2CountriesCodes . indexOf ( str . toUpperCase ( ) ) >= 0 ;
36
35
}
36
+
37
+ export const CountryCodes = validISO31661Alpha2CountriesCodes ;
Original file line number Diff line number Diff line change 1
1
import assertString from './util/assertString' ;
2
2
3
- const localeReg = / ^ [ A - z ] { 2 , 4 } ( [ _ - ] ( [ A - z ] { 4 } | [ \d ] { 3 } ) ) ? ( [ _ - ] ( [ A - z ] { 2 } | [ \d ] { 3 } ) ) ? $ / ;
3
+ const localeReg = / ^ [ A - Z a - z ] { 2 , 4 } ( [ _ - ] ( [ A - Z a - z ] { 4 } | [ \d ] { 3 } ) ) ? ( [ _ - ] ( [ A - Z a - z ] { 2 } | [ \d ] { 3 } ) ) ? $ / ;
4
4
5
5
export default function isLocale ( str ) {
6
6
assertString ( str ) ;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const patterns = {
33
33
HT : / ^ H T \d { 4 } $ / ,
34
34
HU : fourDigit ,
35
35
ID : fiveDigit ,
36
- IE : / ^ (? ! .* (?: o ) ) [ A - z ] \d [ \d w ] \s \w { 4 } $ / i,
36
+ IE : / ^ (? ! .* (?: o ) ) [ A - Z a - z ] \d [ \d w ] \s \w { 4 } $ / i,
37
37
IL : / ^ ( \d { 5 } | \d { 7 } ) $ / ,
38
38
IN : / ^ ( (? ! 1 0 | 2 9 | 3 5 | 5 4 | 5 5 | 6 5 | 6 6 | 8 6 | 8 7 | 8 8 | 8 9 ) [ 1 - 9 ] [ 0 - 9 ] { 5 } ) $ / ,
39
39
IR : / \b (? ! ( \d ) \1{ 3 } ) [ 1 3 - 9 ] { 4 } [ 1 3 4 6 - 9 ] [ 0 1 3 - 9 ] { 5 } \b / ,
You can’t perform that action at this time.
0 commit comments