test_check_digit: Validate an ID Using the Check Digit (DIN ISO 7064, Mod...

View source: R/check_digit.R

test_check_digitR Documentation

Validate an ID Using the Check Digit (DIN ISO 7064, Mod 11,10)

Description

This function verifies whether a given ID is valid by checking its check digit using the DIN ISO 7064, Mod 11,10 algorithm.

Usage

test_check_digit(test)

Arguments

test

A numeric or character string representing the ID. It should be exactly 10 digits long, including the check digit.

Details

The function processes the input as follows: - If the input has 10 digits and does not start with '0', it is assumed to be a ID with a check digit. - If the input has 10 digits and starts with '0', it is considered an old ID without a check digit, and validation cannot be performed. - If the input has 9 digits, it lacks a check digit, so validation is not possible. - If the input format is invalid, an error message is generated.

The function extracts the main ID (without the check digit), computes the expected check digit using 'calculate_check_digit()', and compares it with the provided check digit.

Value

A logical value: 'TRUE' if the check digit is correct, 'FALSE' otherwise. Returns 'FALSE' with an error message if the input format is invalid.

Examples

test_check_digit("1000001381")  # Returns TRUE if the check digit is correct
test_check_digit("1000001121")  # Another valid ID
test_check_digit("1007002482")  # Returns FALSE if the check digit is incorrect


DIZtools documentation built on Nov. 6, 2025, 1:10 a.m.