Skip to content

refactor: merge Node into PatchBuilder for a fluent API#33

Merged
brunoga merged 1 commit intomainfrom
refactor/fluent-builder
Feb 18, 2026
Merged

refactor: merge Node into PatchBuilder for a fluent API#33
brunoga merged 1 commit intomainfrom
refactor/fluent-builder

Conversation

@brunoga
Copy link
Copy Markdown
Owner

@brunoga brunoga commented Feb 18, 2026

This PR simplifies the manual patch construction API by merging the Node and PatchBuilder types into a single, fluent PatchBuilder[T].

Key changes:

  • Navigation methods (Field, Index, etc.) now return a new *PatchBuilder[T] pointing to the sub-path.
  • Operation methods (Set, Put, Add, Delete, etc.) now return the same *PatchBuilder[T] for chaining.
  • Error handling is now stateful: errors are recorded in the builder and returned by Build().
  • Removed the need for .Root() calls.

Example of new API:

b := deep.NewPatchBuilder[MyStruct]()
b.Field("Name").Set("old", "new")
b.Field("Tags").Add(0, "first")
patch, err := b.Build()

- Merged Node and PatchBuilder[T] into a single type\n- Simplified API by removing .Root() and separate Node type\n- Added support for method chaining (fluent API)\n- Implemented stateful error handling in builder\n- Updated all tests and examples to use the new API
@brunoga brunoga merged commit 06a0084 into main Feb 18, 2026
1 check passed
@brunoga brunoga deleted the refactor/fluent-builder branch February 18, 2026 15:49
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