kopia lustrzana https://github.com/reiver/greatape
18 wiersze
260 B
Go
18 wiersze
260 B
Go
|
package validators
|
||
|
|
||
|
import "regexp"
|
||
|
|
||
|
func PostalCodeIsValid(postalCode string) bool {
|
||
|
// Optional
|
||
|
if postalCode == "" {
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
match, err := regexp.MatchString("^\\d{10}$", postalCode)
|
||
|
if err != nil || !match {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return true
|
||
|
}
|