Enum Class CustomValidatorStrategy

java.lang.Object
java.lang.Enum<CustomValidatorStrategy>
org.citrusframework.validation.CustomValidatorStrategy
All Implemented Interfaces:
Serializable, Comparable<CustomValidatorStrategy>, Constable

public enum CustomValidatorStrategy extends Enum<CustomValidatorStrategy>
Defines how custom validators are applied during message validation.

Historical behavior:
By default, custom validators were executed exclusively. This meant that when a custom validator was provided, the default validation logic (such as body or JSON validation) was skipped entirely. For example, in the snippet below the body validation would have no effect on the test result:

 ReceiveMessageAction receiveAction = new ReceiveMessageAction.Builder()
         .getMessageBuilderSupport()
         .body("expected body")
         .validate((message, context) -> customValidatorInvoked.set(true))
         .build();
 

This behavior originally existed to allow users to fully replace the default validation logic — for example, by providing custom JSON validation that must not be duplicated or interfered with by the built-in validators.

New behavior option:
In some scenarios this exclusivity can be unexpected or misleading. For these cases the COMBINED strategy allows Citrus to run both the default validators and the custom validator logic together.

  • Enum Constant Details

  • Method Details

    • values

      public static CustomValidatorStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CustomValidatorStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null