ccc.client.validation
Class AbstractValidations

java.lang.Object
  extended by ccc.client.validation.AbstractValidations
Direct Known Subclasses:
Validations

public abstract class AbstractValidations
extends java.lang.Object

Base implementation of non platform-specific validations.

Author:
Civic Computing Ltd.

Field Summary
static int MAX_NUMBER_OF_PARAGRAPHS
          MAX_NUMBER_OF_PARAGRAPHS : int.
static int MIN_PASSWORD_LENGTH
          MIN_PASSWORD_LENGTH : int.
static java.lang.String NO_BRACKETS
          NO_BRACKETS : String.
protected static UIConstants UI_CONSTANTS
          UI_CONSTANTS : UIConstants.
protected static UIMessages UI_MESSAGES
          UI_MESSAGES : UIMessages.
static java.lang.String VALID_CHARACTERS
          VALID_CHARACTERS : String.
static java.lang.String VALID_PASSWORD_CHARACTERS
          VALID_PASSWORD_CHARACTERS : String.
static java.lang.String VALID_URL
          VALID_URL : String.
static java.lang.String VALID_USERNAME_CHARACTERS
          VALID_USERNAME_CHARACTERS : String.
 
Constructor Summary
AbstractValidations()
           
 
Method Summary
 java.lang.String emptyOrNumber(java.lang.String value, java.lang.String label)
          Create a validator that checks a field contains only numeric characters (0-9).
 java.lang.String matchingPasswords(java.lang.String pw1, java.lang.String pw2)
          Factory method for password matching validators.
 java.lang.String minLength(java.lang.String value, java.lang.String label, int min)
          Validates that input is not too short.
 java.lang.String noBrackets(java.lang.String value, java.lang.String label)
          Validates text so it does not contain bracket < > characters.
 java.lang.String notEmpty(java.lang.String value, java.lang.String label)
          Validates that value is not empty.
 java.lang.String notValidEmail(java.lang.String value, java.lang.String label)
          Validates email.
 java.lang.String notValidResourceName(java.lang.String value, java.lang.String label)
          Validates resource name.
 java.lang.String notValidURL(java.lang.String url)
          Validates a URL.
 java.lang.String notValidUserName(java.lang.String value, java.lang.String label)
          Validates user name.
abstract  java.lang.String notValidXML(java.lang.String definition)
          Validates that xml is valid.
 java.lang.String passwordStrength(java.lang.String pw)
          Factory method for password strength validators.
 ErrorReporter reportErrors(Window window)
          Create a new error reporter.
 java.lang.String validateMetadataValues(java.util.Map<java.lang.String,java.lang.String> data)
          Factory method for metadata validators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_PASSWORD_LENGTH

public static final int MIN_PASSWORD_LENGTH
MIN_PASSWORD_LENGTH : int.

See Also:
Constant Field Values

VALID_CHARACTERS

public static final java.lang.String VALID_CHARACTERS
VALID_CHARACTERS : String.

See Also:
Constant Field Values

VALID_USERNAME_CHARACTERS

public static final java.lang.String VALID_USERNAME_CHARACTERS
VALID_USERNAME_CHARACTERS : String.

See Also:
Constant Field Values

VALID_PASSWORD_CHARACTERS

public static final java.lang.String VALID_PASSWORD_CHARACTERS
VALID_PASSWORD_CHARACTERS : String.

See Also:
Constant Field Values

NO_BRACKETS

public static final java.lang.String NO_BRACKETS
NO_BRACKETS : String.

See Also:
Constant Field Values

VALID_URL

public static final java.lang.String VALID_URL
VALID_URL : String.

See Also:
Constant Field Values

MAX_NUMBER_OF_PARAGRAPHS

public static final int MAX_NUMBER_OF_PARAGRAPHS
MAX_NUMBER_OF_PARAGRAPHS : int.

See Also:
Constant Field Values

UI_CONSTANTS

protected static final UIConstants UI_CONSTANTS
UI_CONSTANTS : UIConstants.


UI_MESSAGES

protected static final UIMessages UI_MESSAGES
UI_MESSAGES : UIMessages.

Constructor Detail

AbstractValidations

public AbstractValidations()
Method Detail

reportErrors

public ErrorReporter reportErrors(Window window)
Create a new error reporter.

Parameters:
window - The window that will report the error.
Returns:
The error reporter for the specified window.

notValidURL

public java.lang.String notValidURL(java.lang.String url)
Validates a URL.

Parameters:
url - The URL.
Returns:
True if the input is valid, false otherwise.

notEmpty

public java.lang.String notEmpty(java.lang.String value,
                                 java.lang.String label)
Validates that value is not empty.

Parameters:
value - The string to validate.
label - The label of the field to validate.
Returns:
The error message as a string or NULL if the value is valid.

notValidResourceName

public java.lang.String notValidResourceName(java.lang.String value,
                                             java.lang.String label)
Validates resource name. Fails if name contains spaces etc.

Parameters:
value - The value to test.
label - The field label.
Returns:
The error message as a string or NULL if the value is valid.

notValidUserName

public java.lang.String notValidUserName(java.lang.String value,
                                         java.lang.String label)
Validates user name. Fails if name contains spaces etc.

Parameters:
value - The value to test.
label - The field label.
Returns:
The error message as a string or NULL if the value is valid.

notValidEmail

public java.lang.String notValidEmail(java.lang.String value,
                                      java.lang.String label)
Validates email.

Parameters:
value - The value to test.
label - The field label.
Returns:
The error message as a string or NULL if the value is valid.

minLength

public java.lang.String minLength(java.lang.String value,
                                  java.lang.String label,
                                  int min)
Validates that input is not too short.

Parameters:
value - The value to test.
label - The field label.
min - The minimum length of the string.
Returns:
The error message as a string or NULL if the value is valid.

noBrackets

public java.lang.String noBrackets(java.lang.String value,
                                   java.lang.String label)
Validates text so it does not contain bracket < > characters.

Parameters:
value - The value to test.
label - The field label.
Returns:
The error message as a string or NULL if the value is valid.

matchingPasswords

public java.lang.String matchingPasswords(java.lang.String pw1,
                                          java.lang.String pw2)
Factory method for password matching validators.

Parameters:
pw1 - The password to check.
pw2 - The password to check.
Returns:
The error message as a string or NULL if the value is valid.

passwordStrength

public java.lang.String passwordStrength(java.lang.String pw)
Factory method for password strength validators.

Parameters:
pw - The password to check.
Returns:
The error message as a string or NULL if the value is valid.

emptyOrNumber

public java.lang.String emptyOrNumber(java.lang.String value,
                                      java.lang.String label)
Create a validator that checks a field contains only numeric characters (0-9).

Parameters:
value - The value to test.
label - The field label.
Returns:
The error message as a string or NULL if the value is valid.

validateMetadataValues

public java.lang.String validateMetadataValues(java.util.Map<java.lang.String,java.lang.String> data)
Factory method for metadata validators.

Returns:
The error message as a string or NULL if the value is valid.

notValidXML

public abstract java.lang.String notValidXML(java.lang.String definition)
Validates that xml is valid.

Parameters:
definition - The string to validate.
Returns:
The error message as a string or NULL if the value is valid.


Copyright © 2010. All Rights Reserved.