Skip to content

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

Closed
Insei wants to merge 3 commits into
feat/more-rulesfrom
feat/tags-complete
Closed

Insei wants to merge 3 commits into
feat/more-rulesfrom
feat/tags-complete

Conversation

@Insei

@Insei Insei commented Oct 19, 2026

Copy link
Copy Markdown
Owner

On top 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:30
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.
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.

1 participant