Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
deankarn committed Aug 26, 2023
1 parent 49637f9 commit 2bc076e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ Please see https://pkg.go.dev/github.com/go-playground/validator/v10 for detaile
Baked-in Validations
------

### Special Notes:
- If new to using validator it is highly recommended to initialize it using the `WithRequiredStructEnabled` option which is opt-in to new behaviour that will become the default behaviour in v11+. See documentation for more details.
```go
validate := validator.New(validator.WithRequiredStructEnabled())
```

### Fields:

| Tag | Description |
Expand Down
2 changes: 1 addition & 1 deletion _examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var validate *validator.Validate

func main() {

validate = validator.New()
validate = validator.New(validator.WithRequiredStructEnabled())

validateStruct()
validateVariable()
Expand Down
18 changes: 9 additions & 9 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Example #2
This validates that the value is not the data types default zero value.
For numbers ensures value is not zero. For strings ensures value is
not "". For slices, maps, pointers, interfaces, channels and functions
ensures the value is not nil.
ensures the value is not nil. For structs ensures value is not the zero value when using WithRequiredStructEnabled.
Usage: required
Expand All @@ -256,7 +256,7 @@ ensures the value is not nil.
The field under validation must be present and not empty only if all
the other specified fields are equal to the value following the specified
field. For strings ensures value is not "". For slices, maps, pointers,
interfaces, channels and functions ensures the value is not nil.
interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_if
Expand All @@ -273,7 +273,7 @@ Examples:
The field under validation must be present and not empty unless all
the other specified fields are equal to the value following the specified
field. For strings ensures value is not "". For slices, maps, pointers,
interfaces, channels and functions ensures the value is not nil.
interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_unless
Expand All @@ -290,7 +290,7 @@ Examples:
The field under validation must be present and not empty only if any
of the other specified fields are present. For strings ensures value is
not "". For slices, maps, pointers, interfaces, channels and functions
ensures the value is not nil.
ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_with
Expand All @@ -307,7 +307,7 @@ Examples:
The field under validation must be present and not empty only if all
of the other specified fields are present. For strings ensures value is
not "". For slices, maps, pointers, interfaces, channels and functions
ensures the value is not nil.
ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_with_all
Expand All @@ -321,7 +321,7 @@ Example:
The field under validation must be present and not empty only when any
of the other specified fields are not present. For strings ensures value is
not "". For slices, maps, pointers, interfaces, channels and functions
ensures the value is not nil.
ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_without
Expand All @@ -338,7 +338,7 @@ Examples:
The field under validation must be present and not empty only when all
of the other specified fields are not present. For strings ensures value is
not "". For slices, maps, pointers, interfaces, channels and functions
ensures the value is not nil.
ensures the value is not nil. For structs ensures value is not the zero value.
Usage: required_without_all
Expand All @@ -352,7 +352,7 @@ Example:
The field under validation must not be present or not empty only if all
the other specified fields are equal to the value following the specified
field. For strings ensures value is not "". For slices, maps, pointers,
interfaces, channels and functions ensures the value is not nil.
interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value.
Usage: excluded_if
Expand All @@ -369,7 +369,7 @@ Examples:
The field under validation must not be present or empty unless all
the other specified fields are equal to the value following the specified
field. For strings ensures value is not "". For slices, maps, pointers,
interfaces, channels and functions ensures the value is not nil.
interfaces, channels and functions ensures the value is not nil. For structs ensures value is not the zero value.
Usage: excluded_unless
Expand Down

0 comments on commit 2bc076e

Please sign in to comment.