Fix POTA reference prefix validation (#109)

* Fix POTA reference prefix validation

* Update "what's new" for v0.1.7
pull/110/head v0.1.7
Jean-Marc MEESSEN 10 months ago committed by GitHub
parent 3a1a218b2e
commit 8ded553835
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,11 +1,15 @@
# What's new?
## v0.1.6
## v0.1.7
* Support parsing 5-digit POTA reference numbers by @k0emt (issue #105).
* Fix POTA reference prefix validation (issue #108).
## Previous releases
### v0.1.6
* Support parsing 5-digit POTA reference numbers by @k0emt (issue #105).
### v0.1.5
* Fix "S2S contacts not recognized properly" (issue #78)

@ -51,10 +51,11 @@ func ValidateWwff(inputStr string) (ref, errorMsg string) {
return wrongInputStr, errorMsg
}
var validPotaRegexp = regexp.MustCompile(`^[\d]{0,1}[A-Z]{1,2}-[\d]{4,5}$`)
var validPotaRegexp = regexp.MustCompile(`^[\d]{0,1}[A-Z]{1,2}[\d]{0,1}-[\d]{4,5}$`)
// ValidatePota verifies whether the supplied string is a valid POTA reference.
// The syntax is: AA-CCCCC: AA = national prefix, CCCCC = 4 or 5-digit numeric code (e.g. ON-00001).
// Note that the national prefix can start with a number, must have 1 or 2, and can end with a number
func ValidatePota(inputStr string) (ref, errorMsg string) {
inputStr = strings.ToUpper(strings.TrimSpace(inputStr))
wrongInputStr := "*" + inputStr

@ -88,6 +88,16 @@ func TestValidatePota(t *testing.T) {
args{inputStr: "4x-0258"},
"4X-0258", "",
},
{
"Good ref (country ref containing a digit)",
args{inputStr: "HB0-0258"},
"HB0-0258", "",
},
{
"Good ref (country ref containing a digit)",
args{inputStr: "E7-0258"},
"E7-0258", "",
},
{
"Good ref (5 digit park)",
args{inputStr: "k-10177"},

Loading…
Cancel
Save