Can I call a custom function from a button action function?

Can I call a custom function from a button action function?

Most buttons that I have perform some common actions. For example, they perform a security check. The owner of the record must equal the logged in user. Or the logged in user must be the manager of the record owner. This prevents users from submitting changes to records they do not own.

I would like to make a custom function called, say, userPermissionCheck that I can call within the custom action function for each button. Instead of including a copy of the code in 10 buttons, I would have 1 function used by 10 buttons. This reduces code management cost and risk of errors introduced by having multiple copies of the code.

I have read the forums and have not found a solution. This looks close: https://www.zoho.com/crm/developer/docs/functions/set-up-functions.html#Function_REST-API. Am I supposed to create a stand-alone custom function and call it using the API in the button's custom action function?