Last active
October 17, 2022 18:51
-
-
Save apzuk3/b7ecfbb22e3fcd638594fe0fb59d3f82 to your computer and use it in GitHub Desktop.
Validation rules
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" | |
type User struct { | |
Email string `json:"email" validate:"required,email"` | |
Name string `json:"name" validate:"required,min=2,max=100"` | |
} | |
func main() { | |
u := User{} | |
err := validate.Validate(a) | |
fmt.Fatal(err) | |
} |
where is validate
got from?
It will throw the error: undeclared name: validate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
err := validate.Validate(u)
Small correction.