prepVal should accept a second parameter which forces the function to output using a given SQL datatype.
Acceptable values could include boolean, integer, varchar, float or any other SQL datatype or abbreviation. If a problem occurs during casting to a datatype, an error should be thrown.