How to check if user has write Permission to a tag in script

How can we check in code / expression if a user has write permission (depending on custom permission of read only permission) on a tag?

I do know about the hasRole() function, but I would like to check independent from role definition if the user can write to the tag.

Thanks !