Welcome to docs.opsview.com

Validation

You should always validate all data coming in from textfields.

There are currently 3 mechanisms for validation:

  • blockInvalidKeys in forms.js
  • validation_via keyword in TT
  • server-side validation (see scheduling downtime as an example)

Use each mechanism as appropriate. You may even need to use a combination of all three.

If you are using the validation framework, you need to call the validation when there are fields that you want passed to the backend, but are hidden out of view. This could happen when:

  • You move from one tab to another
  • You collapse a service group's worth of service checks (in the Monitors tab)

The general principle is that you should validate fields when you are making things invisible.

validation_via

This is just a shortcut method that uses validation.js from http://www.tetlaw.id.au/view/javascript/really-easy-field-validation.

If you set validation_via ⇒ 1, will use the model definition. Set this definition with:

__PACKAGE__->constrain_column_regexp( name => q{/^[\w-]+$/} => invalidCharacter );

The 1st column is the attribute, the 2nd is the regexp (must be in string notation) and the 3rd is the keyword for internationalisation. A prefix of “ui.admin.edit.validation.” will be added. You will need to add the full string to root/dummy so that is gets picked up when scanning files.

You can also use validation_via with a class: validation_via ⇒ { class ⇒ “OpsviewDB::Servicegroup”, name ⇒ “name” }