Skip to content

Commit

Permalink
Fix POTA reference prefix validation (#109)
Browse files Browse the repository at this point in the history
* Fix POTA reference prefix validation

* Update "what's new" for v0.1.7
  • Loading branch information
jmMeessen authored Nov 24, 2023
1 parent 3a1a218 commit 8ded553
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 6 additions & 2 deletions doc/whats_new.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion fleprocess/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions fleprocess/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 8ded553

Please sign in to comment.