Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "github.com/asaskevich/govalidator"
- uuid "github.com/satori/go.uuid"
- )
- type Student struct {
- ID uuid.UUID ` valid:"required"`
- }
- func main() {
- uid, _ := uuid.FromString("738b4a92-868b-4fea-a4bb-00fdfb27f05a")
- student := Student{
- ID: uid,
- }
- govalidator.SetFieldsRequiredByDefault(true)
- valid, err := govalidator.ValidateStruct(student)
- if !valid {
- fmt.Println(err.Error())
- }
- /*
- test case
- fb11dbae-76c3-4a2b-baf7-92aeb29374fd : valid
- 738b4a92-868b-4fea-a4bb-00fdfb27f05a : invalid
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement