Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions air_waybills.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"regexp"
)

var regAirWayBill = regexp.MustCompile(`^\d{3}[ -]?(\d{8})$`)

type AirWaybillItem struct {
AwbNumber string `json:"awb_number"`
AwbStatus string `json:"awb_status"`
Expand Down Expand Up @@ -69,12 +71,7 @@ func (client *Client) CreateAnAirWayBill(ctx context.Context, params AirWaybillP
return nil, errors.New(ErrMissingAwbNumber)
}

regexPattern := `^\d{3}[ -]?(\d{8})$`
matched, err := regexp.MatchString(regexPattern, params.AwbNumber)
if err != nil {
return nil, err
}

matched := regAirWayBill.MatchString(params.AwbNumber)
if !matched {
return nil, errors.New(ErrInvalidAirWaybillFormat)
}
Expand Down