com.ecyrd.jspwiki.ui
Class InputValidator

java.lang.Object
  extended by com.ecyrd.jspwiki.ui.InputValidator

public final class InputValidator
extends Object

Provides basic validation services for HTTP parameters. Two standard validators are provided: email address and standard input. Standard input validator will reject any HTML-like input, and any of a number of special characters.

Since:
2.3.54
Version:
$Revision: 1.4 $ $Date: 2006/02/04 21:46:39 $
Author:
Andrew Jaquith

Field Summary
static int EMAIL
           
protected static Pattern EMAIL_PATTERN
           
static int STANDARD
           
protected static Pattern UNSAFE_PATTERN
           
 
Constructor Summary
InputValidator(String form, WikiSession session)
          Constructs a new input validator for a specific form and wiki session.
 
Method Summary
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 Detail

STANDARD

public static final int STANDARD
See Also:
Constant Field Values

EMAIL

public static final int EMAIL
See Also:
Constant Field Values

EMAIL_PATTERN

protected static final Pattern EMAIL_PATTERN

UNSAFE_PATTERN

protected static final Pattern UNSAFE_PATTERN
Constructor Detail

InputValidator

public InputValidator(String form,
                      WikiSession session)
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
session - the wiki session
Method Detail

validateNotNull

public final 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 final 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 -
Returns:
returns true if valid, false otherwise

validate

public final 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 final 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