Jump to content

Validating input in trigger?


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...