org.mentawai.rule
Class OptionsRule

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

public class OptionsRule
extends Object
implements Rule

A rule to validate number of options. (derived from IntegerRule) You can also specify min and max values.

Author:
Sergio Oliveira

Constructor Summary
OptionsRule(int min)
          Creates a IntegerRule with a min value.
OptionsRule(int min, int max)
          Creates a IntegerRule with a min and max values.
 
Method Summary
 boolean check(String field, Action action)
          Check and validate the given field from the give action.
static OptionsRule getInstance(int min)
           
static OptionsRule 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionsRule

public OptionsRule(int min)
Creates a IntegerRule with a min value.

Parameters:
min - The minimum value for the integer.

OptionsRule

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

Parameters:
min - The minium value for the integer.
max - The maximum value for the integer.
Method Detail

getInstance

public static OptionsRule getInstance(int min)

getInstance

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

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.


Copyright © 2013. All Rights Reserved.