detect_credit_card() — langchain Function Reference
Architecture documentation for the detect_credit_card() function in _redaction.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49["detect_credit_card()"] be639235_9a02_cc2d_5a7d_637d822fb3b3["_redaction.py"] 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49 -->|defined in| be639235_9a02_cc2d_5a7d_637d822fb3b3 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294["_passes_luhn()"] 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49 -->|calls| 2b14d9ef_16cf_fd2a_5e5f_1d51c05d3294 style 8ccbd42d_daf9_c9d1_b6b8_ad43da8f7d49 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/_redaction.py lines 71–95
def detect_credit_card(content: str) -> list[PIIMatch]:
"""Detect credit card numbers in content using Luhn validation.
Args:
content: The text content to scan for credit card numbers.
Returns:
A list of detected credit card matches.
"""
pattern = r"\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b"
matches = []
for match in re.finditer(pattern, content):
card_number = match.group()
if _passes_luhn(card_number):
matches.append(
PIIMatch(
type="credit_card",
value=card_number,
start=match.start(),
end=match.end(),
)
)
return matches
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does detect_credit_card() do?
detect_credit_card() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py.
Where is detect_credit_card() defined?
detect_credit_card() is defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py at line 71.
What does detect_credit_card() call?
detect_credit_card() calls 1 function(s): _passes_luhn.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free