All Known Subinterfaces:
ArtifactValidation

public interface Validation
Defines a validation for a ComponentAst within an ArtifactAst.

Runtime and modules may implement their own validations by implementing this interface.

Implementations must be stateless.

Since:
1.0
  • Method Details

    • getName

      String getName()
      Returns:
      an internal name for this validation.
    • getDescription

      String getDescription()
      Returns:
      a user-friendly description of the validation.
    • getLevel

      Validation.Level getLevel()
      Returns:
      the severity level of a failure of this validation.
    • applicable

      Predicate<List<ComponentAst>> applicable()
      Determines if this validation has to be applied to a given component. The predicate will receive the hierarchy of the component, being the component asked for the last element of the list, and the root element the first one.

      Refer to ComponentAstPredicatesFactory.

      Returns:
      the predicate to determine if this validation has to be applied to a given component hierarchy.
    • validate

      default Optional<ValidationResultItem> validate(ComponentAst component, ArtifactAst artifact)
      Runs this validation in the provided component.

      This method will only be called for components for which the applicable() predicate was true, but only if validateMany(ComponentAst, ArtifactAst) is not implemented.

      Refer to the factory methods in ValidationResultItem for creating the object to be returned.

      Parameters:
      component - the component under validation
      artifact - the full artifact, for any context needed for the validation
      Returns:
      empty if the validation passed, or a result object describing the failure otherwise.
    • validateMany

      default List<ValidationResultItem> validateMany(ComponentAst component, ArtifactAst artifact)
      Runs this validation in the provided component.

      This method will only be called for components for which the applicable() predicate was true.

      Refer to the factory methods in ValidationResultItem for creating the object to be returned.

      Parameters:
      component - the component under validation
      artifact - the full artifact, for any context needed for the validation
      Returns:
      empty if the validation passed, or a result object describing the failure otherwise.