Skip to content

Aditional: case-insensitive check for BIC #1636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/additional/bic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* BIC pattern: BBBBCCLLbbb (8 or 11 characters long; bbb is optional)
*
* Validation is case-insensitive. Please make sure to normalize input yourself.
*
* BIC definition in detail:
* - First 4 characters - bank code (only letters)
* - Next 2 characters - ISO 3166-1 alpha-2 country code (only letters)
Expand All @@ -12,5 +14,5 @@
* - Last 3 characters - branch code, optional (shall not start with 'X' except in case of 'XXX' for primary office) (letters and digits)
*/
$.validator.addMethod( "bic", function( value, element ) {
return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value );
return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value.toUpperCase() );
}, "Please specify a valid BIC code" );
2 changes: 2 additions & 0 deletions src/additional/iban.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* IBAN is the international bank account number.
* It has a country - specific format, that is checked here too
*
* Validation is case-insensitive. Please make sure to normalize input yourself.
*/
$.validator.addMethod( "iban", function( value, element ) {

Expand Down
14 changes: 14 additions & 0 deletions test/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,20 @@ test( "bic", function() {
ok( method( "AAFFFRP1" ), "Valid BIC" );
ok( method( "DEUTDEFFAB1" ), "Valid BIC" );
ok( method( "DEUTDEFFAXX" ), "Valid BIC" );

// BIC accept also lowercased values
ok( !method( "pbnkdef" ), "Invalid BIC: too short" );
ok( !method( "deutdeffa1" ), "Invalid BIC: disallowed length" );
ok( !method( "pbnkdeffxxx1" ), "Invalid BIC: too long" );
ok( !method( "1bnkdeff" ), "Invalid BIC: invalid digit" );
ok( !method( "ingddeffxaa" ), "Invalid BIC: invalid char" );

ok( method( "deutdeff" ), "Valid BIC (lowercase value)" );
ok( method( "deutdeffxxx" ), "Valid BIC (lowercase value)" );
ok( method( "pbnkde2f" ), "Valid BIC (lowercase value)" );
ok( method( "ingdde91xxx" ), "Valid BIC (lowercase value)" );
ok( method( "ingddef2" ), "Valid BIC (lowercase value)" );
ok( method( "deutdeffab1" ), "Valid BIC (lowercase value)" );
} );

test( "postcodeUK", function() {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy