mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 17:29:15 +08:00
refactored nodes model
This commit is contained in:
16
models/validation.go
Normal file
16
models/validation.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
func CheckYesOrNo(fl validator.FieldLevel) bool {
|
||||
return fl.Field().String() == "yes" || fl.Field().String() == "no"
|
||||
}
|
||||
|
||||
func CheckRegex(fl validator.FieldLevel) bool {
|
||||
re := regexp.MustCompile(fl.Param())
|
||||
return re.MatchString(fl.Field().String())
|
||||
}
|
Reference in New Issue
Block a user