Interface ValidationContext

All Superinterfaces:
RuntimeType.Api<ValidationContextConfig>

public interface ValidationContext extends RuntimeType.Api<ValidationContextConfig>
Context of TypeValidator.check(ValidationContext, Object), also used to validate constraints using #check(ConstraintValidator, Object).
  • Method Details

    • builder

      Create a new fluent api builder for a ValidationContext.
      Returns:
      a new builder
    • create

      Create a new validation context from a configuration.
      Parameters:
      config - configuration to use
      Returns:
      a new validation context
    • create

      Create a new validation context customizing its configuration.
      Parameters:
      builderConsumer - consumer to update the builder
      Returns:
      a new validation context
    • create

      static ValidationContext create(Class<?> rootType)
      Create a new validation context for a given root type, where we do not have an instance to serve as root.
      Parameters:
      rootType - type of the root validation object
      Returns:
      a new validation context
    • create

      static ValidationContext create(Class<?> rootType, Object rootObject)
      Create a new validation context for a given root type and object.
      Parameters:
      rootType - type of the root validation object
      rootObject - instance of the root validation object, note that this may be null
      Returns:
      a new validation context
    • response

      ValidationResponse response()
      The overall validation response current available on this context. Calling this method will clear the current response.

      Alternative method to clear the current response is throwOnFailure().

      Returns:
      the response combined from all check(io.helidon.validation.spi.ConstraintValidator, Object) calls.
    • throwOnFailure

      default void throwOnFailure()
      Throws a Validation exception in case the current response is not valid, returns normally otherwise. Calling this method will clear the current response.
    • check

      void check(ConstraintValidator validator, Object object)
      Run the provided check on the provided object. Adds the validator response to this context's validation response.
      Parameters:
      validator - the type validator or constraint validator to run
      object - the object to check
    • scope

      Enter a new scope. The validation context internally maintains a path used to create constraint violations.
      Parameters:
      location - the location we are entering
      name - name of the location (i.e. class name for type, method signature for method)
      Returns:
      a new scope, should be used with try with resources to run any checks nested within the scope
      See Also: