Function is accepting varchar when input is set to INT
This is how MySQL liberally performs implicit type conversion. Seeing that the function wants an integer parameter, the server tries to convert whatever you supply (a character string) into an integer. If the string only contains digits, the conversion is trivial. If the string contains digits first and then some non-digits, those latter are truncated at the first non-digit, and the remainder is converted to an integer. If the string begins with non-digits, it is converted to a 0.

dbfiddle