go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.06k stars 1.29k forks source link

Missing translation for rfc3339 #1248

Closed mila-rodriguez-netapp closed 3 months ago

mila-rodriguez-netapp commented 3 months ago

Package version eg. v9, v10:

v10

require (
    github.com/go-playground/universal-translator v0.18.1
    github.com/go-playground/validator/v10 v10.19.0
)

Issue, Question or Enhancement:

The rfc3339 rule has no translation in english or spanish.

Code sample, to showcase or reproduce:

Type:

type Event struct {
    EventTime string `json:"eventTime" validate:"required,rfc3339"`
}

Result:

"Key: 'Event.EventTime' Error:Field validation for 'EventTime' failed on the 'rfc3339' tag"

Tried with English translations:

v := validator.New()
en := english.New()
uni := ut.New(en, en)

trans, _ := uni.GetTranslator("en")
en_translations.RegisterDefaultTranslations(v, trans)

event := Event{}
err := validate.Struct(event)
validationErrors := err.(validator.ValidationErrors)
failures := validationErrors.Translate(trans)

Poked through the code and I don't see any in the spanish translations either. Probably missing across the board.