Enjoying the University of Central Florida (UCF) in Orlando the past few days. Go Knights! While visiting the campus I spent some down time at the Student Union developing a custom activity for Orchard Core Workflows. If you've read other blog posts of mine, you may know that I am a huge fan of the Workflows Module (and the Rules Engine before it) for extending the functionality of Orchard. I've developed many custom modules, events, and activities for Workflows in Orchard CMS and I plan to do the same for Orchard Core.
While experimenting with Workflows in Orchard Core, I noticed there was no Regex Validator for validating form fields and other data in Workflows using a regular expression. It will probably be available in the first production release of Orchard Core, but for me this was a great opportunity to develop my first workflow activity for Orchard Core, a Regex Validator.
I fired up Orchard Core and created a new website using the built-in Agency Theme (also tested it with my Coming Soon theme). Agency has a contact us form at the bottom of the page, but it's not a working form. It's a placeholder for an Orchard Core Developer to wire-up as appropriate. I decided to connect it to an Orchard Core Workflow that validates the email, and if valid, creates a new Contact. If the email is invalid, it displays an error accordingly.
In addition to the field you wish to validate, the Regex Validator asks for a regular expression for which to validate the data. Based on the results, one can create a new contact as I did here and display a thank you message, display an error message if the data is invalid, send an email, etc. There are several ways to create the workflow depending on your needs. I kept it simple for testing purposes as I am mainly testing the custom workflow activity.