Skip to content

Commit d3e28c4

Browse files
authored
Make docs for required more explicit regarding boolean values (#1261)
`required` validates that the value is not the data types default zero value. For `boolean` the default zero value is `false`. Therefore, a `false` boolean value would be interpreted as not matching the `required` validation and fail. This, in my opinion, is a little unexpected. Judging from the name `required` only, I expected that a `false` boolean value would be ok, since a value was provided. Nevertheless, in my opinion, this behavior should be documented a little more explicitly. Which is why I propose this change to the docs. - [x] Tests exist or have been written that cover this particular change. (this is only a docs change) @go-playground/validator-maintainers
1 parent 0df4e00 commit d3e28c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ Example #2
253253
254254
This validates that the value is not the data types default zero value.
255255
For numbers ensures value is not zero. For strings ensures value is
256-
not "". For slices, maps, pointers, interfaces, channels and functions
256+
not "". For booleans ensures value is not false. For slices, maps, pointers, interfaces, channels and functions
257257
ensures the value is not nil. For structs ensures value is not the zero value when using WithRequiredStructEnabled.
258258
259259
Usage: required

0 commit comments

Comments
 (0)