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.
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)
wherevalidator
is a function that accepts the binary and raisesValueError
on failure. We could supply a trivial validator function that verifies that presence of bytes (or something simple like that) and returnsTrue
. Implementation of more sophisticated validator logic would be up to the developer.