Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: V.oneOfreports all results in case of error + fixed cycle detection #130

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

ssaarela
Copy link
Collaborator

@ssaarela ssaarela commented Jan 30, 2025

  • fix: cycle detection so that e.g. V.oneOf can handle multiple ObjectValidator alternatives.
  • feat: V.oneOf reports all ValidationResults in case of error
  • feat: Path.equals method to compare paths
  • feat: Path.child method to create a new index or property subpath

Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
…ection

Fix `V.oneOf` with multiple object validators failing because of broken cycle detection. This fix makes cycle detection validator (instance) specific. While it may produce funny results with cyclic data, it will be more natural for more common use-cases of `V.oneOf`, `V.allOf` and `V.anyOf`.

Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1e0376f) to head (3a2e648).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #130   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines         4312      4346   +34     
  Branches       676       688   +12     
=========================================
+ Hits          4312      4346   +34     
Files with missing lines Coverage Δ
packages/core/src/objectValidator.ts 100.00% <100.00%> (ø)
packages/core/src/validators.ts 100.00% <100.00%> (ø)
packages/path/src/Path.ts 100.00% <100.00%> (ø)

Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Copy link
Contributor

@karlkeskyla karlkeskyla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

Added a small idea/suggestion to be considered. Approved!

Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
@ssaarela ssaarela merged commit c1a2148 into master Jan 31, 2025
7 checks passed
@ssaarela ssaarela deleted the f/fix-one-of branch January 31, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants