Validate onMessage is a function