Skip to content

chore(deps): Update module github.com/gookit/validate to v2#103

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

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

Conversation

@renovate

@renovate renovate Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
github.com/gookit/validate v1.6.0v2.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).

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 changed the title chore(deps): Update module github.com/gookit/validate to v2 chore(deps): Update module github.com/gookit/validate to v2 - autoclosed Jun 6, 2026
@renovate renovate Bot closed this Jun 6, 2026
@renovate renovate Bot deleted the renovate/github.com-gookit-validate-2.x branch June 6, 2026 13:06
@renovate renovate Bot changed the title chore(deps): Update module github.com/gookit/validate to v2 - autoclosed chore(deps): Update module github.com/gookit/validate to v2 Jun 12, 2026
@renovate renovate Bot reopened this Jun 12, 2026
@renovate renovate Bot force-pushed the renovate/github.com-gookit-validate-2.x branch 2 times, most recently from f98a418 to 533c5e2 Compare June 12, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants