Skip to content

Implement declarative payloads. #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

albu-diku
Copy link
Contributor

Add the logic to automatically package values as a bundle that is formally named. Such a bundle remembers its type, can be validated and provides the facilities allowing its serialisation and deserialisation.

In terms of utility, such a construct allows us to capture a particular grouping of values that belong together and is intended as infrastructure for cases where indirect calling is necessary e.g. programmatic accesss to a JSON API where a client and a server API must exchange strucrured data.

The conditions needed to declare a payload "valid" live with its definition thus any set of values can be immediately tested for validity. The code used to perform the checks is is the existing validation functions, thus there is an upwards path for adoption in existing code.

Use this as the mechanism by which payloads are checked for validity. As part of declaring a bundle definition the expected positional arguments are declared so implement basic length checks that catch missing positional arguments which were required. Each argument itself is also tested aganst an optional validity function which can be specified at the point of definition.

Raise uniform payload exceptions when validation fails. Further, upon failure the exception produced can be serialised directly to JSON with useful messages about the failures that occurred, making it a useful both for the case of generating detailed user-facing reports on the command line as well as potentially reporting errors against fields with UIs.

Add the logic to automatically package values as a bundle that is formally
named. Such a bundle remembers its type, can be validated and provides the
facilities allowing its serialisation and deserialisation.

In terms of utility, such a construct allows us to capture a particular
grouping of values that belong together and is intended as infrastructure
for cases where indirect calling is necessary e.g. programmatic accesss to
a JSON API where a client and a server API must exchange strucrured data.

The conditions needed to declare a payload "valid" live with its definition
thus any set of values can be immediately tested for validity. The code
used to perform the checks is is the existing validation functions, thus
there is an upwards path for adoption in existing code.

Use this as the mechanism by which payloads are checked for validity. As part
of declaring a bundle definition the expected positional arguments are declared
so implement basic length checks that catch missing positional arguments which
were required. Each argument itself is also tested aganst an optional validity
function which can be specified at the point of definition.

Raise uniform payload exceptions when validation fails. Further, upon
failure the exception produced can be serialised directly to JSON with
useful messages about the failures that occurred, making it a useful both
for the case of generating detailed user-facing reports on the command
line as well as potentially reporting errors against fields with UIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant