- - - -```go -package main - -import ( - "github.com/cinar/checker" +```golang +// Custrom checker error containing the item name. +err := NewCheckErrorWithData( + "NOT_FRUIT", + map[string]interface{}{ + "name": "abcd", + }, ) -func main() { - err := checker.IsASCII("Checker") - if err != nil { - // Send the errors back to the user - } +// Register the en-US localized error message for the custom NOT_FRUIT error code. +locales.EnUSMessages["NOT_FRUIT"] = "Name {{ .name }} is not a fruit name." + +errors, valid := v2.CheckStruct(item) +if !valid { + fmt.Println(errors) + // Output: map[Name:Name abcd is not a fruit name.] } ``` -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsAlphanumeric("ABcd1234") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsAmexCreditCard("378282246310005") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsAnyCreditCard("6011111111111117") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsCidr("2001:db8::/32") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsDigits("1234") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsDinersCreditCard("36227206271667") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsDiscoverCreditCard("6011111111111117") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsEmail("user@zdo.com") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsFqdn("zdo.com") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsIP("2001:db8::68") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsIPV4("192.168.1.1") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsIPV6("2001:db8::68") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsISBN("1430248270") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsISBN10("1430248270") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsISBN13("9781430248279") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsJcbCreditCard("3530111333300000") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsLuhn("4012888888881881") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsMac("00:00:5e:00:53:01") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsMasterCardCreditCard("5555555555554444") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - quantity := 5 - - err := checker.IsMax(quantity, 10) - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - s := "1234" - - err := checker.IsMaxLength(s, 4) - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - age := 45 - - err := checker.IsMin(age, 21) - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - s := "1234" - - err := checker.IsMinLength(s, 4) - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - var name string - - err := checker.IsRequired(name) - if err != nil { - // Send the err back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsURL("https://zdo.com") - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsUnionPayCreditCard("6200000000000005") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-- - - -```go -package main - -import ( - "github.com/cinar/checker" -) - -func main() { - err := checker.IsVisaCreditCard("4111111111111111") - - if err != nil { - // Send the errors back to the user - } -} -``` - -
-