Expand description
Validation helpers.
Lightweight validators for common formats. Includes a Luhn implementation for credit card numbers, IBAN/phone/SSN validation, and simple ASCII/UTF-8 checks.
Examples:
use toolchest::validation::{validate_credit_card, is_ascii, is_utf8};
assert!(validate_credit_card("4242424242424242"));
assert!(is_ascii("hello"));
assert!(is_utf8("ok".as_bytes()));Functionsยง
- is_
ascii - True if string is ASCII
- is_utf8
- True if bytes are valid UTF-8
- validate_
credit_ card - Validate credit card number using Luhn algorithm
- validate_
iban - Validate IBAN using the ISO 13616 algorithm (mod-97 == 1)
- validate_
phone - Validate a phone number in E.164 format.
- validate_
ssn - Validate a US Social Security Number (SSN).