forked from elastic/beats
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces initial support for slices into mapval. There are lots of good refactor opportunities this opens up, but I want to draw the line somewhere close. I came across a case where I needed array support in elastic#7545 which I'll be rebasing on this PR. This required a lot of internals refactoring. The highlights are: While the code is more complex, there are fewer special cases, and the control flow is less complicated Making value validation less of a special case Redesigning the walk function to work correctly with slices. This required using reflect extensively. Validating a value involves returning a full mapval.Results map which gets merged into the main Validator results. This is a better internal design and allows for more flexibility. It does mean that custom IsDef validations have a slightly more complicated signature since they need to know the path of the thing they're validating, but that's a good thing in terms of power. Introducing a Path type instead of using simple strings for paths. Moved away from using the MapStr Get method to fetch subkeys. This was required to allow users to specify slice subscript. Tests was added for comparing slices in various ways. As literals, with nested matchers, etc.
- Loading branch information
Showing
11 changed files
with
697 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.