Validation for Singapore National Registration Identity Card numbers (NRIC)


If available in Hex, the package can be installed by adding ex_nric to your list of dependencies in mix.exs:

def deps do
    {:ex_nric, "~> 0.2.0"}

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ex_nric.


import ExNric

{:ok, "S7343684B"} = validate("S7343684B")

{:error, :invalid_format} = validate("x")
{:error, :invalid_format} = validate("x")
{:error, :checksum_error} = validate("G0047750U")


Pull requests to contribute new or improved features, and extend documentation are most welcome.

Please follow the existing coding conventions, or refer to the Elixir style guide.

You should include unit tests to cover any changes. Run mix test to execute the test suite. You should also ensure that dialyzer checks pass. Run mix dialyzer to verify.