|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.enhydra.barracuda.core.forms.FormUtil
Simple Form related utilities
Constructor Summary | |
FormUtil()
|
Method Summary | |
static String |
assertMinMax(String field,
String fieldDescr,
int min,
int max)
This method allows you to assert that a String value falls within a given min/max length range. |
static void |
assertTrue(String errmsg,
boolean expression)
This function simply evaluates a given boolean expression and throws a ValidationException using the specified error message if its not valid |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FormUtil()
Method Detail |
public static String assertMinMax(String field, String fieldDescr, int min, int max) throws ValidationException
This method allows you to assert that a String value falls within a given min/max length range. If min or max is -1, that particular aspect will not be evaluated.
Example usage:
String user = assertMinMax((String) map.get(USER), "User Name", 5, 30);
This would retrieve a username from a map, validate it to ensure that its between 5 and 30 characters in length, and then return the adjusted value (if it was null in the map, it will come back as "", which is convenient for further custom evaluation)
Todo:
field
- the field to be evaluatedfieldDescr
- a description of the field to be included in any error messagesmin
- the minimum length of the String, or -1 if there is no minmax
- the maximum length of the String, or -1 if there is no max
a
- ValidationException if the field is not valid
ValidationException
public static void assertTrue(String errmsg, boolean expression) throws ValidationException
errmsg
- the error message to be used if the expression is invalidexpression
- the expression to be evaluated
ValidationException
- if the expression is not true
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |