org.mentawai.rule
Class RegexRule

java.lang.Object
  extended by org.mentawai.rule.BasicRule
      extended by org.mentawai.rule.RegexRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
EmailRule

public class RegexRule
extends BasicRule

A validation rule applied with a regular expression pattern.

Author:
Sergio Oliveira

Constructor Summary
RegexRule(String pattern)
          Creates a RegexRule with the given regex pattern.
 
Method Summary
 boolean check(String value)
          Check a single input value from this action.
static RegexRule getInstance(String pattern)
           
 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

RegexRule

public RegexRule(String pattern)
Creates a RegexRule with the given regex pattern.

Parameters:
pattern - The regex pattern.
Method Detail

getInstance

public static RegexRule getInstance(String pattern)

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.