Skip to content

fix(deps): update module github.com/gookit/validate to v2#310

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-gookit-validate-2.x
Open

fix(deps): update module github.com/gookit/validate to v2#310
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-gookit-validate-2.x

Conversation

@renovate

@renovate renovate Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
github.com/gookit/validate v1.5.4v2.0.1 age confidence

Release Notes

gookit/validate (github.com/gookit/validate)

v2.0.1

Compare Source

Change Log

Refactor
  • refactor(validators): 比较家族 RV 化搬入 internal/validators (RFC R1) d90d91c
  • refactor(validators): 标量类型族 IsInt/IsString/IsSlice RV 化搬入 internal (RFC R2a) 5a89ab1
  • refactor(validators): 长度族 Length/MinLength/MaxLength RV 化搬入 internal (RFC R2b) c69fc22
  • refactor(validators): 枚举族 Enum/NotIn RV 化搬入 internal (RFC R2c) d079b28
  • refactor(validators): 取串热路径复用载体 String() 消二次反射 (RFC R2d) aeab5ee
  • refactor(data): 提取 StructData.tryGetRV 取值原语,TryGet 委托 (RFC R4.1) 7352c7f
  • refactor(fieldval): Src 懒化 + IsEmpty/String/calcLen 纯 RV + required 载体原生 (RFC R4.2a) 7fbd721
  • refactor(validate): valueValidate 改吃载体 *FieldValue (RFC R4.2b-1) 64b2429
Feature
  • feat(validators): 公开 FieldCtx 接口 + funcMeta 识别 func(FieldCtx)bool 形态 (RFC R3a) bd98903
  • feat(validators): callValidatorValue 按 style 分派 + func(FieldCtx)bool 自定义校验器落地 (RFC R3b) 80805f9
  • feat(validate): struct 源只读校验入口(Validate/ValidateErr/E)自动跳过 safeData 收集 854da39
Update
  • perf(validators): IsBool/IsUint/IsArray/IsMap 提升进 switch + internal RV 版 (RFC R2.5a) db65592
  • perf(validators): Contains/NotContains 提升进 switch 免 reflect.Call (RFC R2.5b) e0351f4
  • perf(validate): 结构体源经 tryGetRV+NewRV 懒构造载体,CheckErr 去 2 装箱 (RFC R4.2b-2) 503863d
  • perf(validators): valueCompare 非指针分支纯 RV,消除 CheckErr 最后 1 装箱 (RFC R4.3) 95431c1
  • perf(validate): scRV 缓存字段 reflect.Value,免 skipCollect 重读并闭合非指针边界 b60f8be
Other
  • docs(perf): RFC validator 入参 RV 化 + FieldLevel 自定义校验器 5260449
  • docs(perf): RFC 命名定为 FieldCtx + 补开发交接(R1 首步) 17dd47f
  • docs(perf): RFC §8 修正 Src 懒装箱触发条件描述 63092bf
  • docs: 更新 RV-native 重构后压测数据与架构现状(CheckErr 0 alloc) c4088a0
  • docs(readme): CheckErr struct-valid 3→0 allocs(RV-native 端到端去装箱) 8f63bfa
  • chore: reanme and merge some go files 59e87c0
  • docs: 同步 struct 源 Validate/ValidateErr 自动免收集后的分配数字 1516f07

v2.0.0

Compare Source

v2.0 keeps breaking changes intentionally minimal (5 items). Core API,
validator names, tag semantics and the DataFace interface are unchanged — most
projects upgrade by bumping the import path to /v2. See
docs/UPGRADE-v2.md for the full migration guide.

Breaking Changes
  • Module path github.com/gookit/validategithub.com/gookit/validate/v2
    (per Go Modules semantic import versioning). Update both go get and all
    import lines.
  • Minimum Go version 1.19 → 1.21 (go.mod).
  • Between signature Between(val any, min, max int64)
    Between(val, min, max any), now consistent with Gt/Lt via valueCompare
    (supports int / uint / float / string). Semantic change for fractional bounds:
    Between(2.9, 1, 2) was true (int64 truncation) and is now false (no more
    truncation). Tag/StringRule usage like between:1,2 is unaffected.
  • Removed deprecated ValueLen(v) — use goutil's reflects.Len(v) instead.
  • Sub-struct cascade now requires the parent field to carry a validate tag.
    Previously a sub-struct field (struct / *struct / slice-of-struct /
    map-of-struct) was always descended into to collect its inner rules. Now
    (CheckSubOnParentMarked defaults to true) cascade only happens when the
    parent field has a validate tag — the value may be empty (validate:""
    is enough to mark it); a named field with no validate tag is no
    longer descended into (Java @Valid-style opt-in). Anonymous embedded
    structs
    (e.g. type Bar struct { Foo }) are exempt — they are part of
    the parent and always cascade regardless of tag; only named sub-struct
    fields require the tag. To restore the v1 "always cascade" behavior globally:
    validate.Config(func(o *validate.GlobalOption){ o.CheckSubOnParentMarked = false }).
    See docs/UPGRADE-v2.md for migration details.

Note: the DataFace interface is unchanged (a redesign was planned during
v2.0 but rejected after profiling); custom DataFace implementers are unaffected.

New Features
  • AddCustomType(fn CustomTypeFunc, types ...any) — register an underlying
    value extractor for custom/wrapped types (e.g. sql.NullString, money types).
    The extracted value flows through the existing validation paths (required /
    numeric compare / length / string rules). CustomTypeFunc func(field reflect.Value) any; returning nil is treated as empty. Mirrors
    go-playground/validator's RegisterCustomTypeFunc. ResetCustomTypes() clears
    the registry. Zero overhead on the hot path when nothing is registered (atomic
    gate short-circuit).
  • NewFactory() + Factory.Struct / Factory.Map + (*Validation).Release()
    — opt-in pooled factory that reuses *Validation instances across many
    same-type validations, amortizing construction cost (allocs roughly halved in
    reuse scenarios). Non-default: Struct / Map / New behavior and lifecycle
    are unchanged.
Performance

Measured on Go 1.25 (count=6) against the v1.6.0 final:

Benchmark v1.6.0 v2.0 default
StructFlat 2295 ns / 34 allocs 1870 ns / 23 allocs (-18% / -32%)
StructNested 2137 ns / 34 allocs 1722 ns / 24 allocs (-19% / -29%)
MapValidate 3314 ns / 72 allocs 3350 ns / 72 allocs (flat)
ValValue 725 ns / 11 allocs 737 ns / 11 allocs (flat)
SliceOfStruct 10900 ns / 208 allocs (dynamic, flat)
FactoryStructReuse (new) 1633 ns / 11 allocs (-52% allocs vs non-factory)

Coverage 95.7% (v1.6.0 was 95.6%).

Internal
  • Pre-convert rule args at build time (drop the runtime convertArgsType).
  • Share immutable static template rules instead of cloning per instance.
  • Fix string validators panicking on non-string fields.
  • Split validators.go by category (compare / string / type files).
  • Sink pure-reflect helpers and fieldValue into internal/ (reflectx,
    fieldval).

v1.6.0

Compare Source

Internal performance refactor. No public API changes — drop-in upgrade.

Performance
  • Cache per-type reflection metadata (field index, tags, kinds, interface
    checks) in a concurrency-safe type cache; access struct fields via
    FieldByIndex instead of FieldByName.
  • Cache the parsed rule template for "static" struct types (no
    ptr-to-struct / slice-of-struct / map-of-struct) and clone it per
    validation, skipping the per-instance tag walk and rule parsing. Dynamic
    types keep the original per-value path.
  • Share built-in error messages instead of copying ~150 entries into every
    Translator; resolve with a custom→builtin fallback.
  • Build the built-in context validators (required*, *Field, file checks)
    lazily on first use instead of eagerly per instance.

Measured (Go 1.25, count=6): static struct validation ~-78% time / -74%
allocations
(10403→2295 ns/op, 132→34 allocs/op); map validation -65% /
-42%; slice-of-struct -37% / -20%. Behavior is byte-identical, guarded by a
rule-collection golden test.

Fixes
  • Fix a stack overflow when building metadata for self-referential or
    mutually-recursive struct types.
  • Fix a data race in Val/Var: concurrent calls shared one validation
    instance and raced on its error/validator maps; each call now uses a
    pooled instance.

v1.5.7

Compare Source

What's Changed

New Contributors

Full Changelog: gookit/validate@v1.5.6...v1.5.7

v1.5.6

Compare Source

Change Log

Fixed
Feature
  • feat: add option to restore request body after reading (#​307) aff7898
Other
  • Add comprehensive GitHub Copilot instructions for gookit/validate (#​306) a96441d
  • ⬆️ dep: upgrade actions and deps to latest version 3dc6a3f
  • 🎨 chore: update some code styles, update git ignore config 0abf62c

What's Changed

New Contributors

Full Changelog: gookit/validate@v1.5.5...v1.5.6

v1.5.5

Compare Source

Change Log

Feature
Other
  • build(deps): bump golangci/golangci-lint-action from 6 to 7 (#​288) 8844616
  • build(deps): bump golangci/golangci-lint-action from 7 to 8 (#​291) 20ea74a
  • 📝 style: modify some code style 8e7eaea
  • 📝 chore: update some code style and some comments 133c917
  • 📝 chore: update some code style and add some testcases 43de360

New Contributors

Full Changelog: gookit/validate@v1.5.4...v1.5.5


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate

renovate Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: docker/go.sum
Command failed: go get -t ./...
go: dagger/docker imports
	dagger/docker/internal/dagger: package dagger/docker/internal/dagger is not in std (/opt/containerbase/tools/golang/1.26.1/src/dagger/docker/internal/dagger)

@renovate
renovate Bot force-pushed the renovate/github.com-gookit-validate-2.x branch from 7218a5a to f39dbba Compare July 12, 2026 09:38
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.

0 participants