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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.