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.
Issue 70: Document array behavior
This addresses #70
The original intent of this PR was to simply update the
README.md
file to include an explanation that arrays are always merged.Just getting set up in a Windows environment revealed an issue in
bin/confidence
(annotate()
is not a function, and resolving the configuration path in Windows - tests have been added/updated for these).Then, as I was developing the examples that I would put in the
README.md
file, I discovered that a base array declared as follows would not be detected as an array, and would be overridden and not merged:This led me to investigate how to make that functionality work consistently in all cases, hence the changes in
lib/store.js
.After making those straightforward changes, I realized that I had no way to use Confidence for the use case posted in my original issue, which was the need for an array in the base configuration to be overridden by a filtered value.
So, I investigated how to go about adding a flag to the base array, such that the behavior of merging or overriding the array could be controlled from within the definition of the configuration. This led to the addition of the
$replace
flag and a custom Joi validation extension.This PR represents a breaking change. And also, it reveals the false assumption and inconsistent behavior that arrays were not always merged to begin with. As such, I would appreciate some guidance. If the maintainer(s) would like a separate PR that just updates the README and some test cases to better demonstrate existing functionality so that it can be merged into the current release without introducing any breaking change, then I will be happy to generate that additional PR.
Thanks!