Skip to content

v7.0.0

Choose a tag to compare

@svyatov svyatov released this 14 Jul 12:55
· 40 commits to main since this release
6909810

sec_id 7.0.0 adds UPI (ISO 4914) support and renames the check-digit concept to checksum across the entire public API. The rename ships with a v7 deprecation bridge that keeps every old name working through v7 (removed in v8) — only the :invalid_check_digit → :invalid_checksum validation error code flips immediately, with no bridge. Upgrading from 6.x? See the migration guide.

Added

  • UPI (ISO 4914, Unique Product Identifier) support via SecID::UPI — the gem's 16th identifier type, and the first offline UPI validator in any language. Validates the 12-character code (fixed QZ prefix, 9-character body, 1 check character) issued by the ANNA Derivatives Service Bureau for OTC-derivatives reporting (CFTC, EMIR, and other global mandates). The check character is computed fully offline via ISO 7064 hybrid MOD 31,30 over the same 30-symbol alphabet as DTI (digits plus consonants; vowels and Y never appear), pinned empirically against DSB-issued vectors — no DSB registry lookup or paywalled ISO 4914 spec required. Like DTI, checksum/calculate_checksum return a String rather than an Integer, since UPI check characters can be letters. A UPI shares the 12-character length bucket with ISIN and can double-detect (ISIN ranked first) when its digit check character also satisfies ISIN's Luhn checksum.

Changed

  • BREAKING: Renamed the check-digit concept to checksum across the entire public API, because the old name was wrong on two axes — DTI's and UPI's check value is a String (it can be a letter, not a digit), and LEI and IBAN carry a two-character check value. The instance and class methods check_digit → checksum, calculate_check_digit → calculate_checksum, and has_check_digit? → has_checksum?; the error class SecID::InvalidCheckDigitError → SecID::InvalidChecksumError; the error code :invalid_check_digit → :invalid_checksum (a hard flip with no dual emission — dual would duplicate errors.details entries, so update any errors.details/explain/ActiveModel details: true matcher immediately); and the :check_digit components key → :checksum in to_h/deconstruct_keys across all nine checkable types. restore/restore! and the Checkable concern name are unchanged. No validation or checksum-arithmetic behavior changed: every identifier that was valid stays valid and every computed value is byte-identical. The old method names, the InvalidCheckDigitError constant, and the :check_digit components key remain as deprecated bridges through v7 (removed in v8); the error code is the only surface with no bridge. See MIGRATION.md for the full upgrade guide

Deprecated

  • The pre-rename check-digit names, kept as v7 bridges and removed in v8: the check_digit / calculate_check_digit / has_check_digit? methods (instance and class level) — each warns via Kernel#warn on every call, visible at Ruby's default verbosity and silenceable with -W0 / $VERBOSE = nil or an app-level Warning override; the SecID::InvalidCheckDigitError constant, a same-object alias of InvalidChecksumError so rescue under either name keeps working; and the :check_digit key, still present alongside :checksum in components / to_h / deconstruct_keys

Full changelog: https://github.com/svyatov/sec_id/blob/v7.0.0/CHANGELOG.md