On insert or update, throw a BadValueError exception if it's a bad value