TACC-Cloud / python-reactors

Python SDK for working with Abaco Actors
1 stars 0 forks source link

Consider how to implement validation of binary content #9

Open mwvaughn opened 3 years ago

mwvaughn commented 3 years ago

As @shwetagopaul92 has implemented binary uploads in the Tapis CLI, we should consider how to implement at least minimal validation of a binary upload. The use case is to allow a developer to enforce requirements on a binary upload. For example, "the binary must be a JPEG or PNG file".

My initial instinct is I don't think we can accomplish this task declaratively, i.e. by simply providing a JSON schema file(s), which is what we're doing for context and message.

One possible function signature might look like: validate_binary(self, binary=None, validator=None, permissive=True) where validator is a function that accepts the binary and raises ValueError on failure. We could supply a trivial validator function that verifies that presence of bytes (or something simple like that) and returns True. Implementation of more sophisticated validator logic would be up to the developer.