Interface Validation
- 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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDefines the severity of a validation failure. -
Method Summary
Modifier and TypeMethodDescriptionDetermines if this validation has to be applied to a given component.getLevel()getName()default Optional<ValidationResultItem>validate(ComponentAst component, ArtifactAst artifact) Runs this validation in the provided component.default List<ValidationResultItem>validateMany(ComponentAst component, ArtifactAst artifact) Runs this validation in the provided component.
-
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
Runs this validation in the provided component.This method will only be called for components for which the
applicable()predicate wastrue, but only ifvalidateMany(ComponentAst, ArtifactAst)is not implemented.Refer to the factory methods in
ValidationResultItemfor creating the object to be returned.- Parameters:
component- the component under validationartifact- the full artifact, for any context needed for the validation- Returns:
emptyif the validation passed, or a result object describing the failure otherwise.
-
validateMany
Runs this validation in the provided component.This method will only be called for components for which the
applicable()predicate wastrue.Refer to the factory methods in
ValidationResultItemfor creating the object to be returned.- Parameters:
component- the component under validationartifact- the full artifact, for any context needed for the validation- Returns:
emptyif the validation passed, or a result object describing the failure otherwise.
-