mikejandreau Posted December 22, 2018 Share Posted December 22, 2018 If I'm using a basic keyword trigger, is there any method I can use to validate the input? For example, if I only want to allow numeric input, or if I want to validate email address formatting? Link to comment
deanishe Posted December 22, 2018 Share Posted December 22, 2018 There's no way to tell Alfred not to accept the input if you're using a Keyword, no. Alfred doesn't run any of your code until after the user hits ↩. The best you can do is show an error notification and re-open Alfred from your script. If you want "live" validation, you need to use a Script Filter. Alfred calls your script while the user is entering their query, so you can validate the input and show an "invalid input" message in the results if need be. For example, my MailTo workflow validates email addresses this way. Link to comment
mikejandreau Posted December 23, 2018 Author Share Posted December 23, 2018 Looks like that'll work. I've thrown a Script Filter in line after the ask for the email address with regex in it. I then fork for regex matches and regex doesn't match. The only issue I see is that I can't loop back from my Script Filter to the Input asking for the email. Ideally I'd like to do: Ask for Email → Regex (script filter) says it doesn't match → Show a Notification → Loop back to Ask for Email step. I don't seem to be able to connect my Regex failure Script Filter back to the input. Am I missing something there? Link to comment
mikejandreau Posted December 23, 2018 Author Share Posted December 23, 2018 To clarify, here's my section of the flow in question. I want to go from the Post Notification Action back to the Email Input, but I can't connect the two. Link to comment
deanishe Posted December 23, 2018 Share Posted December 23, 2018 You can't connect a workflow directly to its own beginning. You have to call it via an External Trigger. Also, you don't put the Script Filter downstream of the Keyword that asks for an email, you use it instead of the Keyword. The Script Filter is run as you're entering the query and provides instant feedback on whether or not the input is valid and doesn't allow the workflow to proceed until it is. If you have any further questions, please upload a copy of the workflow somewhere and post a link: it's very difficult to diagnose issues with a workflow I've never seen. Screenshots aren't enough. Link to comment
deanishe Posted December 23, 2018 Share Posted December 23, 2018 (edited) Here's a simple demo workflow that requires you to enter a valid email address. Edited December 27, 2018 by deanishe Update link (thanks Niki) Link to comment
mikejandreau Posted December 27, 2018 Author Share Posted December 27, 2018 Awesome, thank you for going above and beyond! I'll also adapt this to validate other inputs I need to validate, too. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now