Skip to content

docs: clarify number and numeric validation - #1701

Open
wozhenbang2004 wants to merge 2 commits into
go-playground:masterfrom
wozhenbang2004:patch-1
Open

wozhenbang2004 wants to merge 2 commits into
go-playground:masterfrom
wozhenbang2004:patch-1

Conversation

@wozhenbang2004

Copy link
Copy Markdown

Fixes Or Enhances

Fixes #940.

Clarify that number accepts only ASCII digit strings, whereas numeric also accepts signed and decimal strings. Both tags accept values with Go integer or floating-point types. The documentation now distinguishes the string "1.618" from the value 1.618 and explains the exponent restriction.

Add a runnable Validate.Var example showing the two tags side by side. Validation behavior is unchanged; the example and the existing TestNumber / TestNumeric tests pass before and after the documentation change.

Validation with Go 1.27.4 on Linux:

  • go test -count=1 -v -run '^(TestNumber|TestNumeric|ExampleValidate_Var_numberAndNumeric)$' . passes.
  • go vet ./... passes.
  • golangci-lint run ./... passes with CI-pinned v2.13.1 and Go 1.26.11.
  • The complete CI race/coverage command was run. Its only failures are the existing filesystem and abstract Unix-socket subtests in TestUnixDomainSocketExistsValidation, because this environment rejects socket creation with operation not permitted. The exact unmodified base produces the same failures; all 25 other packages pass.

This change was prepared with AI assistance (ChatGPT, GPT-6 Astra Pro).

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
@wozhenbang2004
wozhenbang2004 requested a review from a team as a code owner November 23, 2026 10:27
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 72.649%. remained the same — wozhenbang2004:patch-1 into go-playground:master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"number" validation fails on string with valid basic float contrary to documentation

2 participants