assertBytes()function

assertBytes(value: unknown, min = 0, max = Number.POSITIVE_INFINITY, caller: AnyCaller = assertBytes): asserts value is Bytes
ParamType
valueunknown
The value to assert. required
minunknown
Minimum allowed length (defaults to 0). Defaults to 0
maxunknown
Maximum allowed length (defaults to Infinity). Defaults to Number.POSITIVE_INFINITY
callerAnyCaller
Function to attribute a thrown error to (defaults to assertBytes itself). Defaults to assertBytes
Return
asserts value is Bytes
Throws
RequiredError
If value is not a byte sequence within the allowed length range.

Assert that an unknown value is a Uint8Array byte sequence (optionally with a min/max length).

Examples

assertBytes(new Uint8Array([1, 2, 3]), 1, 8);