public class ValidateUtil extends Object
public Order saveOrder(order) { ValidateUtil.validate(order); dao.saveOrder(order); }
Modifier and Type | Method and Description |
---|---|
static void |
disableValidationForThread()
Used to indicate that validation should be disabled for the current thread
NOTE: This should always be used in conjunction with the resumeValidationForThread method
|
static Boolean |
getDisableValidation() |
static boolean |
isValidationDisabledForThread() |
static void |
resumeValidationForThread()
Used to indicate that validation should be re-enabled for the current thread
Typically this would be placed in a `finally` block after the disableValidationForThread method is used
|
static void |
setDisableValidation(Boolean disableValidation) |
static void |
validate(Object obj)
Test the given object against all validators that are registered as compatible with the
object class
|
static void |
validate(Object obj,
org.springframework.validation.Errors errors)
Test the given object against all validators that are registered as compatible with the
object class
|
static void |
validateFieldLengths(org.springframework.validation.Errors errors,
Class<?> aClass,
String... fields)
Test the field lengths are valid
|
public static void validate(Object obj) throws ValidationException
obj
- the object to validateValidationException
- thrown if a binding exception occurs
Should throw APIException if errors occur during validation
Should return immediately if validation is disabledpublic static void validate(Object obj, org.springframework.validation.Errors errors)
obj
- the object to validateerrors
- the validation errors foundpublic static void validateFieldLengths(org.springframework.validation.Errors errors, Class<?> aClass, String... fields)
errors
- aClass
- the class of the object being testedfields
- a var args that contains all of the fields from the model
Should pass validation if regEx field length is not too long
Should fail validation if regEx field length is too long
Should fail validation if name field length is too long
Should return immediately if validation is disabled and have no errorspublic static Boolean getDisableValidation()
public static void setDisableValidation(Boolean disableValidation)
public static boolean isValidationDisabledForThread()
public static void disableValidationForThread()
public static void resumeValidationForThread()
Copyright © 2024 OpenMRS Inc.. All rights reserved.