You may check out this library that does all that, validate the South African ID and can also extract a lot of information from it. Like age, gender and citizenship: https://www.nuget.org/packages/SAIDValidator