package validator

import (
	"github.com/gin-gonic/gin/binding"
	"github.com/go-playground/validator/v10"
)

func gender(fl validator.FieldLevel) bool {
	v := fl.Field().String()
	if v != "" && v != "female" && v != "male" {
		return false
	}
	return true
}

func Init() {
	if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
		v.RegisterValidation("gender", gender)
	}
}
