Interface ArtifactValidation

All Superinterfaces:
Validation

public interface ArtifactValidation extends Validation
Defines a validation for an ArtifactAst. This is NOT intended to do validations of the components within the artifact. You must implement Validation for that.

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

Implementations must be stateless.

Since:
1.1
  • Method Details

    • getName

      String getName()
      Specified by:
      getName in interface Validation
      Returns:
      an internal name for this validation.
    • getDescription

      String getDescription()
      Specified by:
      getDescription in interface Validation
      Returns:
      a user-friendly description of the validation.
    • getLevel

      Validation.Level getLevel()
      Specified by:
      getLevel in interface Validation
      Returns:
      the severity level of a failure of this validation.
    • validate

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

      This method will only be called if validateMany(ArtifactAst) is not implemented.

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

      Parameters:
      artifact - the artifact under validation.
      Returns:
      empty if the validation passed, or a result object describing the failure otherwise.
    • validateMany

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

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

      Parameters:
      artifact - the artifact under validation.
      Returns:
      empty if the validation passed, or a result object describing the failure otherwise.
    • applicable

      default Predicate<List<ComponentAst>> applicable()
      Description copied from interface: Validation
      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.

      Specified by:
      applicable in interface Validation
      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)
      Description copied from interface: Validation
      Runs this validation in the provided component.

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

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

      Specified by:
      validate in interface Validation
      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.