Skip to content

Add option to reject readOnly/writeOnly validations#257

Open
byted wants to merge 3 commits intopb33f:mainfrom
byted:feat/strict-reject-readonly-writeonly
Open

Add option to reject readOnly/writeOnly validations#257
byted wants to merge 3 commits intopb33f:mainfrom
byted:feat/strict-reject-readonly-writeonly

Conversation

@byted
Copy link
Copy Markdown

@byted byted commented Apr 10, 2026

Adds a strict config option to fail when the payload contains a property that is marked as readOnly or writeOnly respectively.

Relates to #90

This PR does NOT solve interactions between required and readOnly on the same property. I might be interested in adding this as well but I think this will be a bit more complex for me.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.97%. Comparing base (8828f82) to head (0ea4d3f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #257      +/-   ##
==========================================
+ Coverage   97.94%   97.97%   +0.03%     
==========================================
  Files          64       64              
  Lines        6525     6627     +102     
==========================================
+ Hits         6391     6493     +102     
  Misses        133      133              
  Partials        1        1              
Flag Coverage Δ
unittests 97.97% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

byted added 2 commits April 9, 2026 21:58
When StrictRejectReadOnly is enabled, readOnly properties in requests
are reported as validation errors instead of being silently skipped.
When StrictRejectWriteOnly is enabled, writeOnly properties in
responses are reported similarly.

Addresses pb33f#90
Tests for pb33f#90

- 10 strict-level tests: rejection on/off, direction-specific, nested,
  allOf, combined flags
- 2 error constructor tests for ReadOnlyPropertyError/WriteOnlyPropertyError
- 2 integration tests for request/response dispatch
@byted byted force-pushed the feat/strict-reject-readonly-writeonly branch 3 times, most recently from 3493ec4 to c9e4272 Compare April 10, 2026 05:22
Cover checkReadWriteOnlyViolation calls in:
- recurseIntoDeclaredProperties (explicit + pattern properties)
- validateVariantWithParent (oneOf)
- recurseIntoDeclaredPropertiesWithMerged (oneOf + additionalProperties: false)
- recurseIntoAllOfDeclaredProperties (allOf + additionalProperties: false)
- WithStrictRejectReadOnly/WithStrictRejectWriteOnly option functions
- WithExistingOpts copy of new fields
@byted byted force-pushed the feat/strict-reject-readonly-writeonly branch from c9e4272 to 0ea4d3f Compare April 10, 2026 05:35
@byted byted marked this pull request as ready for review April 10, 2026 05:43
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