Skip to main content

Validator

Struct Validator 

Source
pub struct Validator;
Available on crate feature std only.
Expand description

Validator for ISO 8583 messages and fields

Implementations§

Source§

impl Validator

Source

pub fn validate_pan(pan: &str) -> bool

Validate Primary Account Number (PAN) using Luhn algorithm

The Luhn algorithm (mod-10 algorithm) is used to validate credit card numbers.

§Algorithm
  1. Starting from the rightmost digit (check digit), double every second digit
  2. If doubling results in a two-digit number, add the digits
  3. Sum all digits
  4. If sum is divisible by 10, the number is valid
§Example
use iso8583_core::validation::Validator;

assert!(Validator::validate_pan("4111111111111111"));  // Valid test card
assert!(!Validator::validate_pan("4111111111111112")); // Invalid
Source

pub fn validate_field_format(field: Field, value: &FieldValue) -> Result<()>

Validate field format based on field type

Source

pub fn validate_field_value(field: Field, value: &FieldValue) -> Result<()>

Validate specific field values

Source

pub fn validate_required_fields(msg: &ISO8583Message) -> Result<()>

Validate required fields for a message type

Source

pub fn validate_date_mmdd(date: &str) -> bool

Validate date format (MMDD)

Source

pub fn validate_time_hhmmss(time: &str) -> bool

Validate time format (hhmmss)

Source

pub fn validate_currency_code(code: &str) -> bool

Validate currency code (ISO 4217)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.