Skip to content

3.0.0

Latest
Compare
Choose a tag to compare
@PeterOrneholm PeterOrneholm released this 09 Feb 09:29
· 7 commits to main since this release
63824ae

New features

CoordinationNumber

CoordinationNumber provides parsing methods such as CoordinationNumber.Parse() and CoordinationNumber.TryParse() that can be used like this:

var rawCoordinationNumber = "680164-2395";
if (CoordinationNumber.TryParse(rawCoordinationNumber, out var coordinationNumber))
{
    Console.WriteLine("CoordinationNumber");
    Console.WriteLine(" .ToString(): {0}", coordinationNumber.ToString());
    Console.WriteLine(" .To10DigitString(): {0}", coordinationNumber.To10DigitString());
    Console.WriteLine(" .To12DigitString(): {0}", coordinationNumber.To12DigitString());
    Console.WriteLine(" .RealDay: {0}", coordinationNumber.RealDay;

    Console.WriteLine(" .GetDateOfBirthHint(): {0}", coordinationNumber.GetDateOfBirthHint().ToShortDateString());
    Console.WriteLine(" .GetAgeHint(): {0}", coordinationNumber.GetAgeHint().ToString());

    Console.WriteLine(" .GetGenderHint(): {0}", coordinationNumber.GetGenderHint().ToString());
    
    // IsTestNumber is an extension method from the package ActiveLogin.Identity.Swedish.TestData
    Console.WriteLine(" .IsTestNumber(): {0}", coordinationNumber.IsTestNumber().ToString());
}
else
{
    Console.Error.WriteLine("Unable to parse the input as a CoordinationNumber.");
}

The code above would output (as of 2018-07-23):

CoordinationNumber
 .ToString(): 199908072391
 .To10DigitString(): 990807-2391
 .To12DigitString(): 199908072391
 .RealDay: 7
 .GetDateOfBirthHint(): 1999-08-07
 .GetAgeHint(): 18
 .GetGenderHint(): Male
 .IsTestNumber(): True

CoordinationNumberTestData

We also provides testdata for CoordinationNumber.

using ActiveLogin.Identity.Swedish.TestData; 

var aTestNumber = CoordinationNumberTestData.GetRandom();
aTestNumber.IsTestNumber(); // => true

StrictMode

The library can be configured to use different levels 'strictness' when parsing identity numbers. The different levels are:

  • Off
  • Ten Digits
  • Twelve Digits
  • Ten or Twelve Digits

By default 'Ten or Twelve Digits' is used but it can be overridden when calling Parse and TryParse, e.g.:

// this would fail since the input is not a 12 digit number.
PersonalIdentityNumber.Parse("990807-2391", StrictMode.TwelveDigits); 

Breaking changes

Strict mode

Up until now the parsing of personal identity number have been very allowing. We think there are scenarios where this is still relevant, but from now on by default it will be more strict and only allow the most common patterns (10 or 12 digits). This behaviour can be changed by changing the StrictMode. See details in Readme.

   PersonalIdentityNumber.Parse("990807-2391", StrictMode.Off); 

Removing "Swedish" prefix

The prefix "Swedish" have been removed from SwedishPersonalIdentityNumber, so now it is just "PersonalIdentityNumber".

What's Changed

New Contributors

Full Changelog: 2.0.2...3.0.0