go-playground / validator

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

feature request: Custom time parsing format #1101

Open zsaw opened 1 year ago

zsaw commented 1 year ago

Package version eg. v10:

Issue, Question or Enhancement:

Code sample, to showcase or reproduce:

var form struct {
    ExpirtTime time.Time `validate:"required,datetime=2006-01-02"`
}

out

"parsing time \"2006-01-02\" as \"2006-01-02T15:04:05Z07:00\": cannot parse \"\" as \"T\""
nodivbyzero commented 1 month ago

@zsaw try to use this:

type form struct {
    ExpirtTime string `validate:"required,datetime=2006-01-02"`
}