RsaIdParser.parse constructor

RsaIdParser.parse(
  1. String idNumber
)

idNumber is the 13-digit South African ID number. Throws an exception if the ID number is not valid.

Implementation

RsaIdParser.parse(this.idNumber) {
  if (idNumber.length != 13) {
    throw 'Invalid ID number length';
  }
  dateOfBirth = _parseDateOfBirth(idNumber.substring(0, 6));
  sex = _parseGender(idNumber.substring(6, 10));
  citizenship = _parseCitizenship(idNumber.substring(10, 11));
  race = int.parse(idNumber.substring(11, 12));
  isValid = _validateIdNumber(idNumber);
}