Skip to content

Add hooks for tests #1

@benforeva

Description

@benforeva

I was using Vert on a json string and wanted to run a specific procedure if the string was an empty JSON object. I hacked a solution using :custom_errors and strings (symbols more specifically) but I would like a more elegant solution included in the library.
I propose adding a :hooks key, which would work similarly to the :custom_errors key but returning whatever was specified in the options hash instead of a string. This would allow you to do very convenient callback handling on your data without setting up case statements, or conditionals.
This is also nice for overriding tests, eg. if you want to accept an empty hash or an empty JSON object as valid data you can add a hook for :empty and :empty_json_object.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions