rust_persian_tools/verity_card_number/
errors.rs

1use std::num::ParseIntError;
2
3use thiserror::Error;
4
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[derive(Error, Debug, PartialEq, Eq)]
7pub enum VerifyCardNumberError {
8    #[error("There is an invalid digit in the input.")]
9    InvalidDigit,
10
11    #[error("Input length is invalid.")]
12    InvalidLength,
13
14    #[error("Input format is not a valid card number.")]
15    InvalidCardNumber,
16}
17
18impl From<ParseIntError> for VerifyCardNumberError {
19    fn from(_: ParseIntError) -> Self {
20        VerifyCardNumberError::InvalidDigit
21    }
22}