Input validation

Could someone point me in the right direction for input validation of fields in a plugin. Thanx in advance. I’d like to have the same popup-tip behavior as a missing required field in the post composer.

/david

1 Like

Have a look at

  1. https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/input-tip.js.es6
  2. https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/popup-input-tip.js.es6

Basic usage is something like

# In your templates
{{popup-input-tip validation=<some computed property to show/hide the tip>}}
{{input-tip validation=<some computed property to show/hide the tip>}}
5 Likes

I have tried this and it works great for validating a property continuously while writing. However, I would like to just check if it is set when I press save. Could I trigger the validation in an event action somehow?