com.onresolve.jira.groovy.groovyrunner for ScriptRunner for Jira.
An Epic Link field can only contain links to epics, so you do not need to worry about the second part of your question.
For the first part, SR can now do validators, and yours could be as simple as "epic link is not empty", but you could also consider making it a mandatory field on stories using core Jira functions (the field configuration)
It looks like you're new here. Sign in or register to get started.