|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.scooterframework.common.validation.Validators
com.scooterframework.orm.activerecord.ModelValidators
public class ModelValidators
ModelValidators contains validation methods to validate a model record.
Subclass of ActiveRecord may override one or more of the following methods in order to use validations:
To use a different ModelValidators class, subclass of ActiveRecord must override validators() method.
Examples: public class Post extends ActiveRecord { public void registerRelations() { belongsTo(Topic.class, "mapping: topic_id=id; counter_cache: true"); belongsTo(User.class, "mapping: user_id=id; counter_cache: true"); } public void validatesRecord() { validators().validatesPresenceOf("body"); validators().validatesLengthMaximum("body", 10000); } }
Field Summary | |
---|---|
protected ActiveRecord |
record
The current record instance. |
Fields inherited from class com.scooterframework.common.validation.Validators |
---|
ACCEPTED, CANNOT_BE_BLANK, CANNOT_BE_NULL, CONFIRMATION, EMAIL_PATTERN, EXCEEDING_MAXIMUM, EXCLUSION, INCLUSION, IS_EMAIL, IS_EQUALTO, IS_INSIDE, IS_LARGERTHAN, IS_LARGERTHAN_OR_EQUALTO, IS_LESSTHAN, IS_LESSTHAN_OR_EQUALTO, IS_UNIQUE, IS_WITHIN, NOT_A_NUMBER, OUTOF_RANGE, TOO_LONG, TOO_SHORT, WRONG_LENGTH |
Constructor Summary | |
---|---|
ModelValidators(ActiveRecord record)
Construct a validator. |
Method Summary | |
---|---|
protected java.lang.Object |
getData(java.lang.String fieldName)
Returns value for the specific fieldName of the underlying record. |
protected ValidationResults |
getValidationResults()
Returns validation results. |
void |
validatesUniqenessOf(java.lang.String columnNames,
java.lang.String messageKey)
Validates each field data is unique. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ActiveRecord record
The current record instance.
Constructor Detail |
---|
public ModelValidators(ActiveRecord record)
Construct a validator.
record
- an ActiveRecord instanceMethod Detail |
---|
public void validatesUniqenessOf(java.lang.String columnNames, java.lang.String messageKey)
validatesUniqenessOf
in class Validators
columnNames
- A string of column names separated by comma or blankmessageKey
- key to the message in MessagesResources fileprotected ValidationResults getValidationResults()
getValidationResults
in class Validators
protected java.lang.Object getData(java.lang.String fieldName)
getData
in class Validators
fieldName
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |