RsaIdBook.fromIdNumber constructor
RsaIdBook.fromIdNumber(
- String idNumber
Returns an IdBook
instance from the ID Number of an ID Book, which can be read from
the barcode of the ID Book.
The ID Number is expected to be in the format of a South African ID Number, See https://mybroadband.co.za/news/government/176895-what-your-south-african-id-number-reveals-about-you.html.
If the format above is not adhered to a FormatException will be thrown.
Implementation
factory RsaIdBook.fromIdNumber(String idNumber) {
try {
_validateIdNumber(idNumber);
final dateOfBirth = _dateOfBirth(idNumber);
final gender = _gender(idNumber);
final citizenshipStatus = _citizenshipStatus(idNumber);
return RsaIdBook(
idNumber: idNumber,
gender: gender,
birthDate: dateOfBirth,
citizenshipStatus: citizenshipStatus,
);
} catch (e) {
throw FormatException(
'Could not instantiate ID Book from given ID Number: $e');
}
}