Can I put the selector of cy.contains() inside the variable?

I have a page where I call the locators and import it into my test file.

selector inside cy.contains

The above image, I tried to replace the highlighted one into like loginpage.getErrorMessage()

This is where I store my locator in the different file
ERR_MSG_LOCATOR: ‘[class=”alert”]’

but I am getting an error on that one.