ExodusMovement / schemasafe

A reasonably safe JSON Schema validator with draft-04/06/07/2019-09/2020-12 support.
https://npmjs.com/@exodus/schemasafe
MIT License
156 stars 12 forks source link

Make errors from $ref validation transparent #104

Closed ChALkeR closed 4 years ago

ChALkeR commented 4 years ago

This approach is completely different from what ajv does.

This sees "through" $refs, building full error references from the top, and descending into refs like /something/$ref/path/continues instead of replacing the whole path with the path where the reference resolves to.

This way, it is actually possible to tell where the error originated from, unlike with ajv which makes it hard to understand which schema caused the error in some situations.

Fixes most of #56. oneOf (and similar) tbd.

codecov-commenter commented 4 years ago

Codecov Report

Merging #104 into master will increase coverage by 0.03%. The diff coverage is 100.00%.

Impacted Files Coverage Δ
src/index.js 98.90% <100.00%> (+0.04%) :arrow_up:
src/scope-functions.js 100.00% <100.00%> (ø)
ChALkeR commented 4 years ago

I could perhaps optimize this and would prefer to land the #111, #112 , #113 series first.

ChALkeR commented 4 years ago

~Optimization will conflict with #106, so can we land that first?~ Ah, the other way around.

ChALkeR commented 4 years ago

Will depend on https://github.com/ExodusMovement/schemasafe/pull/115 though.

ChALkeR commented 4 years ago

Seems like we don't need to bother with extra optimization here and can land as is after #115.