_passes_luhn() — langchain Function Reference
Architecture documentation for the _passes_luhn() function in _redaction.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294["_passes_luhn()"] be639235_9a02_cc2d_5a7d_637d822fb3b3["_redaction.py"] 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294 -->|defined in| be639235_9a02_cc2d_5a7d_637d822fb3b3 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49["detect_credit_card()"] 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49 -->|calls| 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294 style 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/_redaction.py lines 222–236
def _passes_luhn(card_number: str) -> bool:
"""Validate credit card number using the Luhn checksum."""
digits = [int(d) for d in card_number if d.isdigit()]
if not _CARD_NUMBER_MIN_DIGITS <= len(digits) <= _CARD_NUMBER_MAX_DIGITS:
return False
checksum = 0
for index, digit in enumerate(reversed(digits)):
value = digit
if index % 2 == 1:
value *= 2
if value > 9: # noqa: PLR2004
value -= 9
checksum += value
return checksum % 10 == 0
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _passes_luhn() do?
_passes_luhn() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py.
Where is _passes_luhn() defined?
_passes_luhn() is defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py at line 222.
What calls _passes_luhn()?
_passes_luhn() is called by 1 function(s): detect_credit_card.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free