javax.validation
Interface ConstraintValidatorContext


public interface ConstraintValidatorContext

Provide contextual data and operation when applying a given constraint validator

Author:
Emmanuel Bernard

Method Summary
 void addError(java.lang.String message)
          Add a new error message.
 void addError(java.lang.String message, java.lang.String property)
          Add a new error message to a given sub property property.
 void disableDefaultError()
          Disable the default error message and default ConstraintViolation object generation.
 java.lang.String getDefaultErrorMessage()
           
 

Method Detail

disableDefaultError

void disableDefaultError()
Disable the default error message and default ConstraintViolation object generation. Useful to set a different error message or generate a ConstraintViolation based on a different property

See Also:
addError(String), addError(String, String)

getDefaultErrorMessage

java.lang.String getDefaultErrorMessage()
Returns:
the current uninterpolated default message

addError

void addError(java.lang.String message)
Add a new error message. This error message will be interpolated.

If isValid returns false, a ConstraintViolation object will be built per error message including the default one unless disableDefaultError() has been called.

Aside from the error message, ConstraintViolation objects generated from such a call contain the same contextual information (root bean, path and so on)

This method can be called multiple times. One ConstraintViolation instance per call is created.

Parameters:
message - new uninterpolated error message.

addError

void addError(java.lang.String message,
              java.lang.String property)
Add a new error message to a given sub property property. The subproperty is relative to the path tot he bean or property hosting the constraint. This error message will be interpolated.

If isValid returns false, a ConstraintViolation object will be built per error message including the default one unless disableDefaultError() has been called.

Aside from the error message and the property path, ConstraintViolation objects generated from such a call contain the same contextual information (root bean, leaf bean etc)

This method can be called multiple times. One ConstraintViolation instance per call is created.

Parameters:
message - new uninterpolated error message.
property - property name the ConstraintViolation is targeting.


Copyright © 2007-2009. All Rights Reserved.