Created
October 18, 2020 08:58
-
-
Save mmitou/8ccbd58b338d5eb1e4661d8a2d995e0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/go-playground/validator/v10" | |
) | |
type Hoge struct { | |
Num string `validate:"number"` | |
Date string `validate:"datetime=20060102"` | |
} | |
func main() { | |
h := Hoge{Num: "1234.01", Date: "20201231"} | |
validate := validator.New() | |
err := validate.Struct(h) | |
if err != nil { | |
fmt.Println(err) | |
} else { | |
fmt.Printf("%+v\n", h) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment