jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

feat(validation): Add a shared storage between all substates of a ValidateState

Open bmfs opened this issue 3 years ago • 3 comments

This new field is similar to the Misc field from a ValidationState but is shared between all a ValidationState and all its child SubStates.

In the project I'm using this library I have a few custom keywords and I need to be able to identify which are the datapaths that are associated with such keywords.

The easiest way I could think of solving this problem was by having this shared storage at the ValidationState level. This way, in my custom keyword ValidateKeyword method, I could save the necessary info and have it available as a result of the validation.

bmfs avatar Jul 09 '21 21:07 bmfs

@Arqu do you think this is something that could be merged in?

bmfs avatar Jul 28 '21 17:07 bmfs

The struct isn't cleared on a new substate and keys can easily collide depending on usage.

Not clearing the struct was the whole point of adding the new field. That is pretty much the difference to the Misc field.

I'll create a basic test that at least confirms my usecase and make the name changes

bmfs avatar Jul 29 '21 10:07 bmfs

At the very least lets document that in the comment on the declaration. Not really sold on the use case but like that it would add a way for others to extend the implementation for their needs.

Ie be more explicit that its not cleared and share the key space for its lifetime.

Arqu avatar Jul 29 '21 10:07 Arqu