Big refactoring of PARCOURSMOB - Initial commit

This commit is contained in:
2022-08-11 17:26:55 +02:00
commit 7225d027c9
65 changed files with 10276 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package formvalidators
import "github.com/go-playground/validator/v10"
type FormValidator struct {
*validator.Validate
}
func New() (f FormValidator) {
validate := validator.New()
validate.RegisterValidation("phoneNumber", PhoneNumber)
f.Validate = validate
return
}

View File

@@ -0,0 +1,15 @@
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())
}