org.mentawai.rule
Class StringRule

java.lang.Object
  extended by org.mentawai.rule.BasicRule
      extended by org.mentawai.rule.StringRule
All Implemented Interfaces:
Rule

public class StringRule
extends BasicRule

A rule to validat Strings. It can also check for min and max values.

Author:
Sergio Oliveira

Constructor Summary
StringRule()
          Creates a StringRule.
StringRule(int min)
          Creates a StringRule with a min value.
StringRule(int min, int max)
          Creates a StringRule with a min and max values.
 
Method Summary
 boolean check(String value)
          Check a single input value from this action.
static StringRule getInstance()
           
static StringRule getInstance(int min)
           
static StringRule getInstance(int min, int max)
           
 Map<String,String> getTokens()
          Returns a map with tokens that can be used in the error messages.
 
Methods inherited from class org.mentawai.rule.BasicRule
check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringRule

public StringRule()
Creates a StringRule.


StringRule

public StringRule(int min)
Creates a StringRule with a min value.

Parameters:
min - The min value to validate.

StringRule

public StringRule(int min,
                  int max)
Creates a StringRule with a min and max values.

Parameters:
min - The min value to validate.
max - The max value to validate.
Method Detail

getInstance

public static StringRule getInstance()

getInstance

public static StringRule getInstance(int min)

getInstance

public static StringRule getInstance(int min,
                                     int max)

getTokens

public Map<String,String> getTokens()
Description copied from interface: Rule
Returns a map with tokens that can be used in the error messages. The tokens in the error messages will be replaced by the token values in this map.

Specified by:
getTokens in interface Rule
Overrides:
getTokens in class BasicRule
Returns:
A map with the token values.

check

public boolean check(String value)
Description copied from class: BasicRule
Check a single input value from this action. Override this method to implement a basic rule for validation.

Specified by:
check in class BasicRule
Parameters:
value - The value to validate.
Returns:
true if the validation was successful.


Copyright © 2013. All Rights Reserved.