validateLength function
Shortcut for a validator to assert that the data has a specific length
Implementation
Validator validateLength(int expectedLength) {
return validate(
(data) => (data.byteLength == expectedLength),
(data) => ArgumentError(
"Data is not the correct length. Expected: $expectedLength bytes, Received: ${data.byteLength} bytes"));
}