Class WStackedValidator

java.lang.Object
eu.webtoolkit.jwt.WValidator
eu.webtoolkit.jwt.WStackedValidator

public class WStackedValidator extends WValidator
A validator that combines multiple validators.

This validator allows you to combine multiple validators into a single one.

For a value to be considered valid by this validator, it must be valid for all of the validators added to it. In case the value is invalid for multiple validators, the validator used to generate the error message is the one with the lowest index.

  • Constructor Details

    • WStackedValidator

      public WStackedValidator()
      Creates an empty stacked validator.
  • Method Details

    • addValidator

      public void addValidator(WValidator validator)
      Adds a validator.

      This adds a validator at the last index if the validator is not already present in the list of validators.

    • insertValidator

      public void insertValidator(int index, WValidator validator)
      Inserts a validator to the given index.

      This inserts a validator at the given index, or at last index if the given index is bigger than the number of validators. Does nothing if the validator is already present in the list of validators.

    • removeValidator

      public void removeValidator(WValidator validator)
      Removes the given validator.
    • getSize

      public int getSize()
      Returns the number of validators.
    • clear

      public void clear()
      Removes all the validators.
    • validate

      public WValidator.Result validate(String input)
      Description copied from class: WValidator
      Validates the given input.

      Note: The signature for this method changed in JWt 3.2.0.

      Overrides:
      validate in class WValidator
    • getJavaScriptValidate

      public String getJavaScriptValidate()
      Description copied from class: WValidator
      Creates a Javascript object that validates the input.

      The JavaScript expression should evaluate to an object which contains a validate(text) function, which returns an object that contains the following two fields:

      • fields: a boolean valid,
      • a message that indicates the problem if not valid.

      Returns an empty string if the validator does not provide a client-side validation implementationq.

      Overrides:
      getJavaScriptValidate in class WValidator
      See Also: