# Plugin development : doc/example to validate editor options

**URL:** <https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075>\
**Category:** Kibana\
**Created:** [April 15, 2018, 1:51pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075 "2018-04-15T13:51:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [April 15, 2018, 1:51pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/1 "2018-04-15T13:51:47Z")

</div>

Is there a doc or an example (url on a github code for example) that shows how to validate editor options and raise properly an error to user ?

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [April 16, 2018, 1:31pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/2 "2018-04-16T13:31:39Z")

</div>

Sorry, I'm not sure I understand the question. Could you be more specific?

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [April 16, 2018, 2:41pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/3 "2018-04-16T14:41:16Z")

</div>

Hi @Bill_McConaghy,

- Suppose I created a visualization plugin
- In edition mode, I have an 'Options' tab with a text parameter named 'Param1'
- Now, user edits visualization, fullfills 'Param1' content, and click on 'Apply Changes' button
- As a plugin developer, I want to catch this event, validate 'Param1' content, and if invalid, raise an error with a clean error message, that will be properly displayed to user as a blocking error : red bar on top with the message, or something like that.
- Do you have a doc or an example that do this feature ? I mean a code that both detect 'Apply Changes' action and which raises a nice error message to user (not a stack trace in browser console)

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [April 16, 2018, 2:50pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/4 "2018-04-16T14:50:31Z")

</div>

Thanks for the details. I found this blog post which goes into pretty good depth about visualization plugin development but did not find anything about form validation:

> **[Creating new Kibana visualizations and embedding them into your own plugin](https://www.elastic.co/blog/developing-new-kibana-visualizations)**
>
> Creating custom Kibana visualizations got much easier as well as embedding them in your own plugins.

  
I'm not sure where there is a good example for what you are trying to do.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [April 16, 2018, 3:11pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/5 "2018-04-16T15:11:13Z")

</div>

You can use angular form validators like `ng-required`as well as html form validators like `required`.

There is also `$scope.visualizeEditor` which is the angular form controller for the whole form.

I am not aware of any documentation or examples around it, but general angular form validation documentation should be a good start.

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [April 16, 2018, 8:01pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/6 "2018-04-16T20:01:07Z")

</div>

Thanks @ppisljar @Bill_McConaghy for your answers !

I would love to use something like `ng-required`, but in my case, it's quite complicated.

To be more precise, I develop [kibana-enhanced-table](http://github.com/fbaligand/kibana-enhanced-table) which is like a Data Table, but with enhanced features.  
I currently add a new feature that allow to 'Split Cols'. So it's a new bucket type.  
I want to force that this bucket is the last one. So I want to raise an error, if it is not the last one.  
But as it not me that generates HTML code (Kibana core does it), I can't add an angular directive.

That's why I would like to listen 'Apply Changes' event.  
Thus, I would like to know which Kibana API to call to display a beautiful error to user (not a stack trace).

Ideally, if you know a plugin (core plugin or community plugin) that does this kind of future, it would be perfect !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 14, 2018, 8:01pm UTC](https://discuss.elastic.co/t/plugin-development-doc-example-to-validate-editor-options/128075/7 "2018-05-14T20:01:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
