parcoursmob/utils/form-validators/phone-numbers.go

16 lines
331 B
Go

package formvalidators
import (
"regexp"
"github.com/go-playground/validator/v10"
)
const phoneNumberRegexStreing = "^((\\+)33|0)[1-9](\\d{2}){4}$"
var phoneNumberRegex = regexp.MustCompile(phoneNumberRegexStreing)
func PhoneNumber(fl validator.FieldLevel) bool {
return phoneNumberRegex.MatchString(fl.Field().String())
}