diff --git a/go.mod b/go.mod index 47b200f..50e375b 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.19 require ( github.com/frozzare/go v1.0.0 github.com/frozzare/go-assert v1.1.0 - github.com/personnummer/go/v3 v3.1.0 + github.com/personnummer/go/v3 v3.1.2 ) diff --git a/go.sum b/go.sum index 71b16a5..fc2e955 100644 --- a/go.sum +++ b/go.sum @@ -6,3 +6,5 @@ github.com/personnummer/go/v3 v3.0.2 h1:tBm+nBmD6NhfazoMV9oUDxXZHMghYhKEmWsnPcJs github.com/personnummer/go/v3 v3.0.2/go.mod h1:VGi8cG/kgQ9c4p8qCTRWxV1IAWUpAf2VF6137TL/Oq0= github.com/personnummer/go/v3 v3.1.0 h1:Bqq6CV9aBrsz+g84Gbyge6rCmpr2uKK//opoJz+3d3M= github.com/personnummer/go/v3 v3.1.0/go.mod h1:piLpoILajZ4xgNA53uzWdTb6VNgYPs4uWdhuTjdHuEM= +github.com/personnummer/go/v3 v3.1.2 h1:pQFk14wsPtSX6WdjhEn7rabg2/NAjGBI3liju2Imgs8= +github.com/personnummer/go/v3 v3.1.2/go.mod h1:piLpoILajZ4xgNA53uzWdTb6VNgYPs4uWdhuTjdHuEM= diff --git a/vendor/github.com/personnummer/go/v3/README.md b/vendor/github.com/personnummer/go/v3/README.md index 3cc39f5..5a8e0ae 100644 --- a/vendor/github.com/personnummer/go/v3/README.md +++ b/vendor/github.com/personnummer/go/v3/README.md @@ -1,4 +1,4 @@ -# personnummer [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/personnummer/go/go.yml?branch=master)](https://github.com/personnummer/go/actions) [![GoDoc](https://godoc.org/github.com/personnummer/go?status.svg)](https://godoc.org/github.com/personnummer/go) [![Go Report Card](https://goreportcard.com/badge/github.com/personnummer/go)](https://goreportcard.com/report/github.com/personnummer/go) +# personnummer [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/personnummer/go/go.yml?branch=master)](https://github.com/personnummer/go/actions) [![GoDoc](https://godoc.org/github.com/personnummer/go?status.svg)](https://pkg.go.dev/github.com/personnummer/go/v3) [![Go Report Card](https://goreportcard.com/badge/github.com/personnummer/go)](https://goreportcard.com/report/github.com/personnummer/go) Validate Swedish personal identity numbers. diff --git a/vendor/github.com/personnummer/go/v3/personnummer.go b/vendor/github.com/personnummer/go/v3/personnummer.go index b71e0c6..2408a8c 100644 --- a/vendor/github.com/personnummer/go/v3/personnummer.go +++ b/vendor/github.com/personnummer/go/v3/personnummer.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" "time" + "unicode" ) const ( @@ -106,6 +107,12 @@ func getCoOrdinationDay(day []byte) []byte { // luhn will test if the given string is a valid luhn string. func luhn(s []byte) bool { + for _, c := range s { + if !unicode.IsNumber(rune(c)) { + return false + } + } + odd := len(s) & 1 var sum int @@ -204,12 +211,6 @@ func (p *Personnummer) parse(pin string, options *Options) error { dateBytes := getCleanNumber(pin) - if len(dateBytes) == 0 || len(dateBytes) < 8 { - return errInvalidSecurityNumber - } - - plus := strings.Contains(pin, "+") - switch len(dateBytes) { case lengthWithCentury: century = string(dateBytes[0:2]) @@ -224,6 +225,8 @@ func (p *Personnummer) parse(pin string, options *Options) error { check = string(dateBytes[9:]) dateBytes = dateBytes[0:6] break + default: + return errInvalidSecurityNumber } if num == "000" { @@ -240,6 +243,8 @@ func (p *Personnummer) parse(pin string, options *Options) error { } } + plus := strings.Contains(pin, "+") + p.Century = century p.Year = year p.FullYear = toString(century + year) diff --git a/vendor/modules.txt b/vendor/modules.txt index 243c4c7..4918d67 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,6 +4,6 @@ github.com/frozzare/go/http2 # github.com/frozzare/go-assert v1.1.0 ## explicit github.com/frozzare/go-assert -# github.com/personnummer/go/v3 v3.1.0 +# github.com/personnummer/go/v3 v3.1.2 ## explicit; go 1.20 github.com/personnummer/go/v3