A data guarantee is a function that throws an Error
if the input doesn't meet whatever specification the data guarantee enforces.
For example:
export function mustBeUuidData(
input: string,
onError: OnError
): void {
if (isUuidData(input)) {
return true;
}
throw onError(new TypeError("input is not a value!!));
}
The key properties of a data guarantee are:
- it is asserting that the input passes a given test, ie that the data it contains is acceptable in some way
- there's no return value, so it doesn't matter if the caller forgets to check it