org.javalite.activejdbc.validation
Class ValidatorAdapter<T extends Model>

java.lang.Object
  extended by org.javalite.activejdbc.validation.ValidatorAdapter<T>
All Implemented Interfaces:
Validator<T>
Direct Known Subclasses:
AttributePresenceValidator, NumericValidator, RegexpValidator

public abstract class ValidatorAdapter<T extends Model>
extends Object
implements Validator<T>

Subclass this class to create custom validators.

Author:
Igor Polevoy

Constructor Summary
ValidatorAdapter()
           
 
Method Summary
 String formatMessage(Locale locale, Object... params)
          Provides default implementation, will look for a property in resource bundle, using set message as key.
 String getMessage()
           
 void setMessage(String message)
          Sets an message on this validator.
abstract  void validate(T m)
          Called by framework when a Model.validate() method called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorAdapter

public ValidatorAdapter()
Method Detail

validate

public abstract void validate(T m)
Description copied from interface: Validator
Called by framework when a Model.validate() method called.

Specified by:
validate in interface Validator<T extends Model>
Parameters:
m - model being validated.

setMessage

public final void setMessage(String message)
Description copied from interface: Validator
Sets an message on this validator.

Specified by:
setMessage in interface Validator<T extends Model>
Parameters:
message - error message.

formatMessage

public String formatMessage(Locale locale,
                            Object... params)
Provides default implementation, will look for a property in resource bundle, using set message as key. If property in resource bundle not found, treats message verbatim.

Specified by:
formatMessage in interface Validator<T extends Model>
Parameters:
locale - locale to use.
params - parameters in case a message is parametrized.
Returns:
formatted message.

getMessage

public String getMessage()


Copyright © 2013. All Rights Reserved.