org.mentawai.rule
Class CrossRule

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

public abstract class CrossRule
extends Object
implements Rule

A rule that compares two or more action input fields for validation.

Author:
Sergio Oliveira

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

Constructor Detail

CrossRule

public CrossRule()
Method Detail

getFieldsToValidate

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

Returns:
String array with the name of the fields

check

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

Parameters:
values - The values to compare.
Returns:
true if the validation was successful.

check

public boolean check(String field,
                     Action action)
Description copied from interface: Rule
Check and validate the given field from the give action.

Specified by:
check in interface Rule
Parameters:
field - The field to validate.
action - The action from where to get the field.
Returns:
true if the validation succeeds.

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


Copyright © 2013. All Rights Reserved.