Throw Error/RangeError for invalid data.