fix incorrect and vague doc comments
Audit ahead of the README/doc.go work (issue #3): - number.go: Min, MinFloat32, MinFloat64 all said "less than or equal to a given maximum" -- copy-pasted from the Max family. They check the minimum. Fixed. - chars_test.go: ExampleExceptChars called Chars, not ExceptChars, so it never exercised the function it documents. - chars.go: "does not contain disallowed characters" was circular. - in.go: NotIn's parameter was named "allow"; renamed to "disallow". - length.go: note that length is bytes (len), not runes -- the "%d characters" messages imply otherwise. - url.go: spell out that ParseRequestURI wants an absolute URL or path. - uuid.go: note lowercase-hex only, version/variant not checked. - error.go: explain Err (the match-anything sentinel), how Error() formats with Data, and what With does. all.go: point at Collect. Comments only; no behaviour change. go vet + go test ./... pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ var (
|
||||
ErrValueNotAllowed = NewError("not allowed")
|
||||
)
|
||||
|
||||
// In validates whether a value is found in a slice of allowed values.
|
||||
// In validates that a value equals one of the allowed values.
|
||||
func In[T comparable](allow ...T) func(T) error {
|
||||
return func(value T) error {
|
||||
for _, cmp := range allow {
|
||||
@@ -16,10 +16,10 @@ func In[T comparable](allow ...T) func(T) error {
|
||||
}
|
||||
}
|
||||
|
||||
// NotIn validates whether a value is not found in a slice of disallowed values.
|
||||
func NotIn[T comparable](allow ...T) func(T) error {
|
||||
// NotIn validates that a value equals none of the disallowed values.
|
||||
func NotIn[T comparable](disallow ...T) func(T) error {
|
||||
return func(value T) error {
|
||||
for _, cmp := range allow {
|
||||
for _, cmp := range disallow {
|
||||
if cmp == value {
|
||||
return ErrValueNotAllowed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user