greatape/app/validators/postal_code_validator.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
}