Skip to content

limoli/kid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KID

GitHub Actions Go Report Card GoDoc GitHub license

About

KID number (actually KID, customer identification) is a number used in bill payment in Norway to identify the payment (regardless of who pays the bill). It can be from 2 and up to 25 digits long. The last digit of the KID number is a check digit. This check digit is calculated from the MOD10 or MOD11 algorithm.

Algorithms

Usage

Validate a KID number

Using MOD10
    kid.Verify(code, new(Luhn10))
Using MOD11
    kid.Verify(code, new(Luhn11))

Generate a KID number

Using MOD10
    luhn10 := kid.Luhn10{}
    checkDigit, err := luhn10.Generate(code)
    // e.g. 7, nil
Using MOD11
    luhn11 := kid.Luhn11{}
    checkDigit, err := luhn11.Generate(code)
    // e.g. '-', nil

Handle errors

  • ErrorInvalidCodeLength: KID has an invalid length
  • ErrorInvalidNumber: KID has an invalid character (not a digit)

License

Released under the MIT License.

About

Validate and generate KID numbers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages