The compiled "checker" should accept path & parent #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previous functionality
In 0.3.0 - 0.6.10 the returned function from compile looked like this:
_schemawas never used butpathStackwas, so it was possible to provide a custom path from code:The custom path was used in error messages and also become part of the path forwarded to custom validators, so they could use that info when validating.
Current functionality: Breaking change
In 0.6.11 this was changed to:
This was breaking change and broke some of our tests, where we use fastest-validator to validate parts of the objects. Custom validators that relies on path in the same way as the example above are used. Currently we have locked to use version 0.6.10
Restored functionality
This PR brings back the 0.6.10 functionality, however; As a breaking change already was introduced in 0.6.11, instead of restoring 0.6.10 functionality as it was (with an unused
_schemaargument) the returned function now looks like this.So it's still a breaking change to what 0.6.10 looked like, but at least it makes it possible, after changing calls from
validate(myObject, null, 'custom.path')tovalidate(myObject, 'custom.path'), to provide custom paths.Tests
Tests have been added that verifies
path, and when calling compile with schemas in an array:parentis used.pathandparent, still works.To be clear: This PR introduces no breaking changes to 0.6.12