Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-5798

Introduce unified validation mechanism to webhooks

XMLWordPrintable

    • Icon: New Feature Request New Feature Request
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 5.0.0alpha1, 5.0.0alpha2
    • Proxy (P), Server (S)

      Most webhooks require to perform input param validation and such validations make as much as 50+% of webhook code. Additionaly there is no unification in validation logic / error messages etc.

      It would be great to introduce built-in object that will implement unified validation logic like this:

      var data = InputValidator.parse([
      	{fields: ['url', 'severity', 'title'], validator: 'required'},
      	{fields: ['url', 'title'], validator: 'string'},
      	{fields: 'title', validator: 'string', options: {'max': 100}},
      	{fields: 'severity', validator: 'integer', options: {'min': 1, 'max': 5}},
      	{fields: 'url', validator: function (value) {
      		if (!value.endsWith('/')) {
      			value += '/';
      		}
      
      		return value;
      	}},
      	{fields: 'title', validator: function (value) {
      		if (value.trim() === '') {
      			throw 'Bebebe, bad value, bebebe!';
      		}
      
      		return value;
      	}},
      	{fields: 'set', validator: 'boolean'}
      ]);

            wiper Andris Zeila
            vjaceslavs Vjaceslavs Bogdanovs
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: