Skip to content

feat!: name object types and separators, and check definitions early - #4

Merged
enilsen16 merged 15 commits into
mainfrom
feat/named-types-and-checks
Oct 22, 2026
Merged

enilsen16 merged 15 commits into
mainfrom
feat/named-types-and-checks

Conversation

@enilsen16

@enilsen16 enilsen16 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #3.

Summary

  • ObjectType, Separator and Prefix are named string types, so an object type, a separator and a prefix cannot be swapped by mistake. Untyped string constants such as ObjectType: "user" still compile.
  • ValidationError.ObjectTypes lists the object types a value was checked against: one for an ID, every member's for a union.
  • Bare() and the parse inputs stay string, because they are the wire and storage boundary.
  • The object type must be lowercase snake_case of at most 63 characters, the TypeID prefix rule. ObjectType.validate checks this with a byte loop, and every constructor fails with ErrInvalidDefinition when the rule is broken. The Elixir package does not check this yet.
  • Check[T]() and CheckUnion[U]() report a bad definition in a test or init, including a generator whose values the type's own validation rejects. They are the Go form of the Elixir compile-time checks.
  • A value without one of the accepted prefixes fails with *WrongPrefixError{Want []Prefix}, for single types and unions. It unwraps to ErrInvalidFormat, so errors.Is checks keep working.

This is a breaking change before v1: ValidationError.ObjectType is replaced by ObjectTypes, and the accessors return the named types.

Tests

  • An internal table test covers the object type rule.
  • check_test.go covers Check, CheckUnion, and the prefix error for a wrong prefix, a missing prefix and a union.

CI runs only on PRs to main. Locally, go test -race, go vet and golangci-lint pass.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ee819c1-d80f-448e-b929-b3b7f0bd28f9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…ition

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid_test.go
…d-checks

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectidproto/objectidproto.go
#	objectidproto/objectidproto_test.go
…n errors

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
…d-checks

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
Base automatically changed from feat/proto-definition-options to main October 22, 2026 16:06
…checks

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
#	objectidproto/objectidproto.go
@enilsen16
enilsen16 marked this pull request as ready for review October 22, 2026 16:07
@enilsen16
enilsen16 merged commit 3856a56 into main Oct 22, 2026
3 checks passed
@enilsen16
enilsen16 deleted the feat/named-types-and-checks branch October 22, 2026 16:08
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