Skip to content

PF-2509 add modulus checks for US - #279

Merged
loreenwong merged 1 commit into
masterfrom
us-routing-number-modulus-check
Oct 29, 2026
Merged

loreenwong merged 1 commit into
masterfrom
us-routing-number-modulus-check

Conversation

@loreenwong

@loreenwong loreenwong commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

https://gocardless.atlassian.net/browse/PF-2509

What

Add valid_us_details? for US pseudo-IBANs. After the existing routing number
checksum, it calls the configured modulus checker's valid_bank_code?, in the
same way valid_australian_details?, valid_nz_details? and
valid_ca_details? already do for AU, NZ and CA.

If no modulus checker is configured, behaviour is unchanged.

Why

For US details the only check was the ABA checksum, and the modulus checker was
never called. The checksum passes some invalid numbers, such as 000000000, so
routing numbers that do not exist were accepted.

Behaviour change

Anyone with a modulus checker configured will now see US routing numbers
rejected when the checker says the bank code does not exist. The error is
bank_code "bank code does not exist". Marked [Breaking] in the changelog, in
line with how the NZ validation change was handled.

Testing

  • Specs for valid_us_details?: with no checker, with a checker that accepts,
    with a checker that rejects, and with a failing checksum.
  • Updated the country specific checks spec for US.

@loreenwong
loreenwong requested a review from a team October 29, 2026 14:10
Comment thread spec/ibandit/iban_spec.rb
}
end

it { is_expected.to be(true) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be being a silly goose - why is iban.valid_us_details true for non-US details?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I've just realised that all methods are the same. But I don't understand why valid_us_details? would return false if the country code is US, that seems counter intuitive

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres a similar test for CA, NZ and AU so I just copied them in, I think the point is that because it uses the default modulus check it should pass too

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, I think I just don't understand this remit well enough 🤦‍♀️

@hux-is-me

Copy link
Copy Markdown

Not sure if relevant needed, but the modulus checker itslef does not have a 'pipeline' (function) for the us and returns the default pipeline that simply says true. Do we want the modulus checker itself to do things or is for now the purpose of this change to allow ibandit to work with us accounts? ps please can we go through ibandit sometime

@loreenwong

Copy link
Copy Markdown
Contributor Author

Not sure if relevant needed, but the modulus checker itslef does not have a 'pipeline' (function) for the us and returns the default pipeline that simply says true. Do we want the modulus checker itself to do things or is for now the purpose of this change to allow ibandit to work with us accounts? ps please can we go through ibandit sometime

I dont think so, i copied the style of CAD, NZ and AUD which also doesnt as they dont have IBANs

@loreenwong
loreenwong merged commit 5207a1c into master Oct 29, 2026
4 checks passed
@loreenwong
loreenwong deleted the us-routing-number-modulus-check branch October 29, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants