Skip to content

feat: complete the rules of the tags of go-playground/validator - #79

Merged
Insei merged 3 commits into
mainfrom
feat/tags-complete
Oct 19, 2026
Merged

Insei merged 3 commits into
mainfrom
feat/tags-complete

Conversation

@Insei

@Insei Insei commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Replaces #77, closed with the deleted base branch of #76.

  • shared: Field.Or — passes when any alternative passes, reports the errors of the first one; Getter reads a field without allocations.
  • Tags: a|b; required_if, required_unless, required_with, required_with_all, required_without, required_without_all; dive into the elements of struct types by the tags of their type (Items[1].Title, recursive types, dive,required for nil elements of []*T, zero allocations); keys/endkeys of map[string]V; gt/lt/ne/eq of strings, numbers, lengths, bools and times; gtfield, ltfield, eqfield, nefield of numbers, nefield of strings; alpha, number, numeric, hexadecimal, excludes, containsany, excludesall, startsnotwith, endsnotwith, eq_ignore_case; omitnil; the escapes 0x2C, 0x7C.
  • Docs: the table of all supported tags with their rules, the list of all unsupported tags of go-playground/validator with what to write in code, and the differences — checked against go-playground/validator v10 (an empty non-nil slice, a map and a pointer to an empty string pass its required; the nil nested structs are skipped; gt of a time compares with now).

The alternatives allocate the errors of the failed ones (documented on Or), a value passing the first alternative doesn't allocate. 100% coverage.

Insei added 3 commits October 19, 2026 12:50
Or passes when the rules of any of the alternatives pass and reports
the errors of the first one; Getter reads the value of a field without
allocations, for the conditions of the rules.
The alternatives a|b, the conditions required_if, required_unless,
required_with, required_with_all, required_without and
required_without_all, dive into the elements of struct types by the tags
of their type, keys and endkeys of map[string]V, gt, lt, ne, the strict
and the not equal rules on fields, the new rules of strings, eq and ne of
bools, gt and lt of times, omitnil, the escapes 0x2C and 0x7C.
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark diff: 15c4169 → 3392ffc (10 runs)

goos: linux
goarch: amd64
pkg: github.com/insei/valigo
cpu: AMD EPYC 9V74 80-Core Processor                
           │  base.txt   │           head.txt            │
           │   sec/op    │   sec/op     vs base          │
Validate-4   122.7n ± 3%   126.0n ± 5%  ~ (p=0.093 n=10)

           │  base.txt  │            head.txt            │
           │    B/op    │    B/op     vs base            │
Validate-4   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

           │  base.txt  │            head.txt            │
           │ allocs/op  │ allocs/op   vs base            │
Validate-4   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

@Insei
Insei merged commit 1d6cc8e into main Oct 19, 2026
6 checks passed
@Insei
Insei deleted the feat/tags-complete branch October 19, 2026 09:53
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (15c4169) to head (efe9edf).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #79    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           38        38            
  Lines         1535      1775   +240     
==========================================
+ Hits          1535      1775   +240     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants