pub fn validate(amka: &str) -> (bool, &str) {
    if !is_string_numeric(amka.to_string()) {
        return (false, "Provided AMKA is not a numeric value");
    }

    if amka.chars().count() != 11 {
        return (false, "Provided number is not 11 digits long");
    }

    let check_date = || -> Result<(), ParseError> {
        let date_part = &amka[..6];
        NaiveDate::parse_from_str(date_part, "%d%m%y")?;
        Ok(())
    };

    if let Err(_err) = check_date() {
        return (
            false,
            "First 6 digits of the provided AMKA do not represent a valid date",
        );
    }

    if !luhn::valid(amka) {
        return (false, "Provided AMKA does not have a valid checkdigit");
    }

    (true, "")
}
/// Validates the given string for AMKA
Validates the given string for AMKA
Validates the given string for AMKA
pub fn validate(amka: &str) -> (bool, &str) {
    if !is_string_numeric(amka.to_string()) {
        return (false, "Provided AMKA is not a numeric value");
    }
    if amka.chars().count() != 11 {
        return (false, "Provided number is not 11 digits long");
    }
    let check_date = || -> Result<(), ParseError> {
        let date_part = &amka[..6];
        NaiveDate::parse_from_str(date_part, "%d%m%y")?;
        Ok(())
    };
    if let Err(_err) = check_date() {
        return (
            false,
            "First 6 digits of the provided AMKA do not represent a valid date",
        );
    }
    if !luhn::valid(amka) {
        return (false, "Provided AMKA does not have a valid checkdigit");
    }
    (true, "")
}
pub fn validate ( amka : & str ) -> ( bool , & str ) { if ! is_string_numeric ( amka . to_string ( ) ) { return ( false , " " ) ; } if amka . chars ( ) . count ( ) != 11 { return ( false , " " ) ; } let check_date = | | -> Result < ( ) , ParseError > { let date_part = & amka [ .. 6 ] ; NaiveDate :: parse_from_str ( date_part , " " ) ? ; Ok ( ( ) ) } ; if let Err ( _err ) = check_date ( ) { return ( false , " " , ) ; } if ! luhn :: valid ( amka ) { return ( false , " " ) ; } ( true , " " ) }
Validates the given string for AMKA
Validates the given string for AMKA
amka
&str
amka
&str