Sanitizes, validates length, character set and Luhn checksum for card numbers, providing masked card number types.
// Source: https://github.com/mperkins0155/hyperswitch | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use std::{collections::HashMap, fmt, ops::Deref, str::FromStr, sync::LazyLock};
use common_utils::errors::ValidationError;
use error_stack::report;
use hyperswitch_masking::{PeekInterface, Strategy, StrongSecret, WithType};
use regex::Regex;
#[cfg(not(target_arch = "wasm32"))]
use router_env::{logger, which as router_env_which, Env};
use serde::{Deserialize, Deserializer, Serialize};
use thiserror::Error;
/// Minimum limit of a card number will not be less than 8 by ISO standards
pub const MIN_CARD_NUMBER_LENGTH: usize = 8;
/// Maximum limit of a card number will not exceed 19
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key