validador

package packages

import (
	"log"

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

func Validator(s interface{}) {
	val := validator.New()
	err := val.Struct(s)

	if err != nil {
		if _, ok := err.(*validator.InvalidValidationError); ok {
			log.Printf("Validator struct error %v", ok)
			return
		}

		for _, err := range err.(validator.ValidationErrors) {
			log.Printf("Field: %v", err.StructField())
			log.Printf("Value: %v", err.Value())
			log.Printf("Tag: %v", err.Tag())
		}
		return
	}
}
Restu Wahyu Saputra