pub fn validate(
code: &str,
alphabet: &Alphabet,
expected_length: usize,
damm_table: &DammTable,
) -> ValidationResultExpand description
Validate a promotional code and return detailed result.
This function checks:
- Code length matches expected length
- All characters are in the alphabet
- Damm check digit is correct
§Arguments
code- The code to validate (including check digit)alphabet- The alphabet used for the codeexpected_length- Expected total length (code_length + 1 for check digit)damm_table- Damm table for check digit validation
§Returns
ValidationResult with detailed information about any validation failure.
§Example
use promocrypt_core::{validate, Alphabet, DammTable, ValidationResult};
let alphabet = Alphabet::default_alphabet();
let damm = DammTable::new(alphabet.len());
let result = validate("INVALIDCODE", &alphabet, 10, &damm);
// result will indicate specific failure reason