org.mentawai.rule
Class EqualRule

java.lang.Object
  extended by org.mentawai.rule.CrossRule
      extended by org.mentawai.rule.EqualRule
All Implemented Interfaces:
Rule

public class EqualRule
extends CrossRule

A validation rule that compares two action input fields for equality.

Author:
Sergio Oliveira

Constructor Summary
EqualRule(String field1, String field2)
          Creates a EqualRule for comparing the fields given.
 
Method Summary
 boolean check(String[] values)
          Check different values from an action input for the validation.
protected  String[] getFieldsToValidate()
          Subclasses should implement this method to indicate which fields from the action input they want to receive for validation.
static EqualRule getInstance(String field1, String field2)
           
 Map<String,String> getTokens()
          Returns a map with tokens that can be used in the error messages.
 
Methods inherited from class org.mentawai.rule.CrossRule
check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EqualRule

public EqualRule(String field1,
                 String field2)
Creates a EqualRule for comparing the fields given.

Parameters:
field1 - The first field
field2 - The second file
Method Detail

getInstance

public static EqualRule getInstance(String field1,
                                    String field2)

getFieldsToValidate

protected String[] getFieldsToValidate()
Description copied from class: CrossRule
Subclasses should implement this method to indicate which fields from the action input they want to receive for validation.

Specified by:
getFieldsToValidate in class CrossRule
Returns:
String array with the name of the fields

check

public boolean check(String[] values)
Description copied from class: CrossRule
Check different values from an action input for the validation. Override this method to implement a cross rule for validation.

Specified by:
check in class CrossRule
Parameters:
values - The values to compare.
Returns:
true if the validation was successful.

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 CrossRule
Returns:
A map with the token values.


Copyright © 2013. All Rights Reserved.