Class ValidationError

    • Method Detail

      • addKey

        public ValidationError addKey​(String key)
        Adds a key to the list of keys that will be tried against IErrorMessageSource to locate the error message string.
        Parameters:
        key - a message key to be added
        Returns:
        this ValidationError for chaining purposes
      • addKey

        public ValidationError addKey​(IValidator<?> validator)
        Shortcut for adding a standard message key which is the simple name of the validator' class
        Parameters:
        validator - validator
        Returns:
        this
      • addKey

        public ValidationError addKey​(IValidator<?> validator,
                                      String variation)
        Shortcut for adding a standard message key variation which is the simple name of the validator class followed by a dot and the variation

        If the variation is empty only the validator's simple class name is used

        Parameters:
        validator - validator
        variation - key variation
        Returns:
        this
      • setVariable

        public ValidationError setVariable​(String name,
                                           Object value)
        Sets a key and value in the variables map for use in substitution.
        Parameters:
        name - a variable name
        value - a variable value
        Returns:
        this ValidationError for chaining purposes
      • getVariables

        public final Map<String,​ObjectgetVariables()
        Retrieves the variables map for this error. The caller is free to modify the contents.
        Returns:
        a Map of variables for this error
      • setVariables

        public final ValidationError setVariables​(Map<String,​Object> vars)
        Sets the variables map for this error.
        Parameters:
        vars - a variables map
        Returns:
        this ValidationError for chaining purposes
      • getMessage

        public final String getMessage()
        Gets the default message that will be used when no message could be located via message keys.
        Returns:
        message the default message used when all keys yield no message
      • setMessage

        public final ValidationError setMessage​(String message)
        Sets message that will be used when no message could be located via message keys.

        Note: No variable substitution is performed on the given message!

        Parameters:
        message - a default message to be used when all keys yield no message
        Returns:
        this ValidationError for chaining purposes
      • setKeys

        public void setKeys​(List<String> keys)
        Sets error keys
        Parameters:
        keys -