package validator

import (
	"regexp"

	"github.com/go-playground/validator/v10"
)

func validateEmail(fl validator.FieldLevel) bool {
	s := fl.Field().String()
	isEmail, _ := regexp.Match(`^\w([\w\-_+]*(\.[\w\-_+]+)?)*@(\w+[\-.])+\w{2,}$`, []byte(s))
	hasValidSize, _ := regexp.Match(`^.{0,64}@.{0,63}$`, []byte(s))

	return isEmail && hasValidSize
}
