Skip to content

Validate present optional record fields at runtime - #3137

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/optional-record-fields
Open

Validate present optional record fields at runtime#3137
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/optional-record-fields

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Runtime record validation checks required fields but ignores optional_fields entirely. A present optional field therefore passes even when its value is incompatible with the declared type.

Validate optional fields only when their key is present, preserving their optional presence contract.

Verification

  • baseline model accepts an invalid present optional value; focused and cumulative candidates reject it while accepting absent/valid values
  • runtime type-checking tests: 15 tests / 302 assertions
  • all 109 runtime files compile on Ruby 4.0.6
  • focused candidate syntax, RuboCop, and diff checks pass

Source-only change; no test file is included.

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