A good place to start would be to follow this tutorial on how to write Connect apps: https://developer.atlassian.com/cloud/jira/platform/getting-started/
Then there is an example validator app linked in the docs: https://bitbucket.org/atlassianlabs/atlassian-connect-jira-workflow-condition-validator-example. You should be able to just clone it and run to play around with to see how validators work. Then it’s just a matter of replacing the expression in that app with one that suits you.
In fact, that example is probably much more complicated than you need. If you are not interested in configuring the validator during configuration, the only thing you need is an entry in your descriptor, without any callbacks to “create”, “edit” or “view” (just skip these properties).
Let me know if you have any questions.