Auto format field using Custom Function

Auto format field using Custom Function

I'm thinking of implementing a Custom Function to automatically format my phone fields.

I envision a Workflow that calls that Custom Function when my "Phone" field of a "Contact" gets edited.

Up to here it seems pretty straight forward.

However, how do I scale this to all my phone number fields in "Contacts" and further all phone number fields to "Accounts"?

Is this possible with Custom Functions or is there a better way of implementing this?

Oliver