Package org.apache.wiki.ui

# Class InputValidator

java.lang.Object
org.apache.wiki.ui.InputValidator

public final class InputValidator extends Object
Provides basic validation services for HTTP parameters. Three standard validators are provided: email address, identifier and standard input. Standard input validator will reject any HTML-like input, and any of a number of special characters. ID validator rejects HTML and quoted strings, and a couple of special characters.

Since:
  2.3.54

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`EMAIL`
Input validator for e-mail addresses.
`static final int`
`ID`
`static final int`
`STANDARD`
Standard input validator.

## Constructor Summary

Constructors
Constructor
Description
`InputValidator(String form, org.apache.wiki.api.core.Context context)`
Constructs a new input validator for a specific form and wiki session.

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`isBlank(String input)`
Returns `true` if a supplied string is null or blank
`boolean`
`validate(String input, String label, int type)`
Validates a string against a particular pattern type: e-mail address, standard HTML input, etc.
`boolean`
`validateNotNull(String input, String label)`
Validates a string against the `STANDARD` validator and additionally checks that the value is not `null` or blank.
`boolean`
`validateNotNull(String input, String label, int type)`
Validates a string against a particular pattern type and additionally checks that the value is not `null` or blank.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### STANDARD

public static final int STANDARD
Standard input validator.

See Also:
  - Constant Field Values

### EMAIL

public static final int EMAIL
Input validator for e-mail addresses.

See Also:
  - Constant Field Values

### ID

public static final int ID

Since:
  2.4.82
See Also:
  - Constant Field Values

## Constructor Details

### InputValidator

public InputValidator(String form, org.apache.wiki.api.core.Context context)
Constructs a new input validator for a specific form and wiki session. When validation errors are detected, they will be added to the wiki session's messages.

Parameters:
  `form` - the ID or name of the form this validator should be associated with
  `context` - the wiki context

## Method Details

### validateNotNull

public boolean validateNotNull(String input, String label)
Validates a string against the `STANDARD` validator and additionally checks that the value is not `null` or blank.

Parameters:
  `input` - the string to validate
  `label` - the label for the string or field ("E-mail address")
Returns:
  returns `true` if valid, `false` otherwise

### validateNotNull

public boolean validateNotNull(String input, String label, int type)
Validates a string against a particular pattern type and additionally checks that the value is not `null` or blank. Delegates to `validate(String, String, int)`.

Parameters:
  `input` - the string to validate
  `label` - the label for the string or field ("E-mail address")
  `type` - the pattern type to use (e.g., `STANDARD`, `EMAIL`.
Returns:
  returns `true` if valid, `false` otherwise

### validate

public boolean validate(String input, String label, int type)
Validates a string against a particular pattern type: e-mail address, standard HTML input, etc. Note that a blank or null string will always validate.

Parameters:
  `input` - the string to validate
  `label` - the label for the string or field ("E-mail address")
  `type` - the target pattern to validate against (`STANDARD`, `EMAIL`)
Returns:
  returns `true` if valid, `false` otherwise

### isBlank

public static boolean isBlank(String input)
Returns `true` if a supplied string is null or blank

Parameters:
  `input` - the string to check
Returns:
  `true` if `null` or blank (zero-length); `false` otherwise