Skip to main content

Module card

Module card 

Source
Expand description

What a card entry knows about itself: its brand, whether its number passes the Luhn check, how its number is grouped, how long its security code is, and its expiry month and year. Pure functions, no store, no seal. docs/specs/SPEC_VAULT_CARD_ENTRIES_FULL_CARD_DATA_AND_AUTOFILL_2026_11_08.md §4.

A card’s number, expiry month and year, code, name and ZIP are sealed parts. What the pane and the reminders can read without the key is the plain brand and default fields and the expires date (the last day of the expiry month), which settle keeps in step with the parts on every save.

Constants§

BRAND
The plain field that holds the brand (visa, mastercard, …), worked out from the number.
DEFAULT
The plain field that marks the person’s default card (yes, or absent).
KIND
The kind these functions are for.
LEGACY_EXPIRY
A pre-split expiry, “MM/YY” or “MM/YYYY”. Still read; a save writes exp_month and exp_year instead.

Functions§

brand
The brand a number belongs to by its first digits, or an empty string.
cvc_length
How many digits the security code has: four for American Express, three otherwise.
expired
Whether a card is past its month: from the first day of the month after.
expiry_of
The expiry a set of parts holds: its month and year, or the older single part read as one.
group
A number grouped for reading: 4-6-5 for American Express, fours for the rest.
last_day
The last day of the expiry month: the card works through it.
luhn
Whether the digits of number pass the Luhn check.
month_text
“03” for March.
normalize_expiry
A month and year from any of “3/27”, “03/27”, “03/2027”, “0327”, “032027”, “03-2027” or “2027-03”.
normalize_number
A number’s digits when it is only digits, spaces and dashes; None for anything else.
part_value
A card part as a fill or a command asks for it. The older expiry is read from the month and year when the card has no such part, as “MM/YY”.
settle
Makes a card’s parts and plain fields agree, on every save (by the person, an agent or an import): the number as digits, the expiry as exp_month and exp_year (the older expiry read into them and dropped), the brand worked out from the number, expires set to the last day of the expiry month for the reminders, and the default flag kept to yes. A month or year that is not one is refused; a number with anything but digits is left as typed (the pane warns, the Vault doesn’t decide). Any other kind is left alone.