Prevent Sign-in flow on condition and set error message

Hey guys, our team is using the transformUsername function to modify the username before we send the credentials for auth and sign in. For some conditions in transformUsername we want to prevent the credentials from being sent to okta to auth and prevent sign in and directly set the error message. If I’m not mistaken this can be achieved by not calling the line
OktaUtil.completeLogin
This behaviour can be achieved by using a flag variable and conditionally calling the above line right, but how do I set the error message field as then I will not have the error object. Is it possible to just access the element and set the inner message as text/html