From ceffc4932d268229061d2d1595c21728e190ed8e Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Sun, 29 Dec 2024 04:51:01 -0800 Subject: [PATCH] Small update on examples in the documentation. (#157) # Describe Request Small update on examples in the documentation. # Change Type Documentation improvements. --- v2/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/v2/README.md b/v2/README.md index 3b7f41d..8d0dd36 100644 --- a/v2/README.md +++ b/v2/README.md @@ -164,13 +164,13 @@ When adding checker struct tags to a slice, you can use the `@` prefix to indica ```golang type Person struct { Name string `checkers:"required"` - Emails []string `checkers:"@max-len:1 max-len:4"` + Emails []string `checkers:"@max-len:2 max-len:64"` } ``` In this example: -- `@max-len:1` ensures that the `Emails` slice itself has at most one item. -- `max-len:4` ensures that each email string within the `Emails` slice has a maximum length of 4 characters. +- `@max-len:2` ensures that the `Emails` slice itself has at most two items. +- `max-len:64` ensures that each email string within the `Emails` slice has a maximum length of 64 characters. # Localized Error Messages @@ -192,7 +192,7 @@ checker.RegisterLocale(locales.DeDE, locales.DeDEMessages) _, err := checker.IsEmail("abcd") if err != nil { - fmt.Println(err) + fmt.Println(err.ErrorWithLocale(locales.DeDE)) // Output: Keine gültige E-Mail-Adresse. } ``` @@ -217,7 +217,7 @@ Error messages are generated using Golang template functions, allowing them to i err := NewCheckErrorWithData( "NOT_FRUIT", map[string]interface{}{ - "name": name, + "name": "abcd", }, )