16 lines
331 B
Go
Executable File
16 lines
331 B
Go
Executable File
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())
|
|
}
|