org.openmrs.validator
Class ValidateUtil

java.lang.Object
  extended by org.openmrs.validator.ValidateUtil

public class ValidateUtil
extends java.lang.Object

This class should be used in the *Services to validate objects before saving them.

The validators are added to this class in the spring applicationContext-service.xml file.

Example usage:

  public Order saveOrder(order) {
        ValidateUtil.validate(order);
        dao.saveOrder(order);
  }
 

Since:
1.5

Constructor Summary
ValidateUtil()
           
 
Method Summary
protected static java.util.List<org.springframework.validation.Validator> getValidators(java.lang.Object obj)
          Fetches all validators that are registered
 void setValidators(java.util.List<org.springframework.validation.Validator> newValidators)
          Deprecated. in favor of using HandlerUtil to reflexively get validators
static void validate(java.lang.Object obj)
          Test the given object against all validators that are registered as compatible with the object class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidateUtil

public ValidateUtil()
Method Detail

setValidators

@Deprecated
public void setValidators(java.util.List<org.springframework.validation.Validator> newValidators)
Deprecated. in favor of using HandlerUtil to reflexively get validators

Parameters:
newValidators - the validators to set

getValidators

protected static java.util.List<org.springframework.validation.Validator> getValidators(java.lang.Object obj)
Fetches all validators that are registered

Parameters:
obj - the object that will be validated
Returns:
list of compatibile validators

validate

public static void validate(java.lang.Object obj)
                     throws APIException
Test the given object against all validators that are registered as compatible with the object class

Parameters:
obj - the object to validate
Throws:
APIException - thrown if a binding exception occurs
Expected behavior:
throw APIException if errors occur during validation

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change