close

Filter

loading table of contents...

Site Manager Developer Manual / Version 2304

Table Of Contents

5.1.7 Validator Classes

<DocumentType name="article">
  <PropertyType name="Author">
    <Validator class="NotEmpty2"/>
  </PropertyType>
</DocumentType>

Example 5.9. Example for the use of a validator


When a document is checked in, validators test whether certain conditions are fulfilled. At the present time, four validators are delivered with the Site Manager. These check, whether a field

  • is filled,

  • is filled with a certain pattern,

  • contains an integer in a specified range

  • A link list field can be checked for a minimal, maximal number of entries and for unique entries. In addition, the allocation of a linklist field can be checked.

Another class can be used to combine several validators and one always validates to "true".

In addition, own validator classes can be written. These classes implement the interface hox.corem.editor.validation.Validator2 and must be specified via the element <Validator>.

Validator Description
SetValidator2

Using this class several validators can be combined as subelements Validator of the element Validator. SetValidator2 uses the Validator2 interface and replaces the deprecated SetValidator class.

Example:

<DocumentType name="Text">

<PropertyType name="Content">

<Validator class="SetValidator2">

<Validator class="my.very.own.TextValidator"/>

<Validator class="my.very.own.SpellValidator"/>

<Validator class="my.very.own.AddValidator"/>

</Validator>

</PropertyType>

</DocumentType>

NotEmpty2 This validator checks whether entries have been made in a field. If the field is empty, an error message is created and the document is not accepted for checking in. The validator must be named as the value in the Attribute class of the element <Validator>. NotEmpty2 uses the Validator2 interface and replaces the deprecated NotEmpty class.
GenericValidator This validator checks whether a field is filled with the appropriate pattern. If the entry is wrong, an error message is created and the document is not accepted for checking in. The validator is called implicitly, if the attribute validPattern of the element <PropertyType> is used. As a valid Pattern, any regular expression can be used (see the element <PropertyType> in Section 5.2.3, “Configuring Document Types”).
MinMaxIntegerValidator

This validator checks whether a field is filled with an integer in the appropriate range. If the entry is wrong, an error message is created and the document is not accepted for checking in. This validator must be set with the class attribute within the element <Validator>. The min and max values can be provided with the attributes min and max.

Example: <Validator class="MinMaxIntegerValidator" min="1" max="10"/>

LinkListValidator

This validator checks whether a linklist field is filled with a minimum (attribute minLength) or a maximum (attribute maxLength) number of entries. It also checks if a field is filled with unique entries only (attribute uniqueEntries) and if the entries are all below a specified path (attribute path).

Example: <Validator class="LinkListValidator" minLength="1" path="/looks">

Thus, at least one entry must be contained in the linklist field and the documents belonging to the entries must be located below the folder /looks.

AlwaysTrueValidator This validator always validates to "true". If you use multiple editor XML configuration files (see Chapter 3, Operation and Configuration), you can use the validator to override other validators.

Table 5.26. Validator classes


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.