Interface ValidatorFactory
@ProviderType
public interface ValidatorFactory
Each
Validator is created via the according factory.
The factories should be registered via the ServiceLoader mechanism-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringReserved prefix for all validator ids integrated in this JAR. -
Method Summary
Modifier and TypeMethodDescription@Nullable ValidatorcreateValidator(@NotNull ValidationContext context, @NotNull ValidatorSettings settings) Creates a new validator for the given context.@NotNull StringgetId()Returns the validator ID.intThe service ranking will influence the order in which the validators will be called.booleanReturns whether the validator should by default also called for subpackages.
-
Field Details
-
ID_PREFIX_JACKRABBIT
Reserved prefix for all validator ids integrated in this JAR. No custom validator ids must start with this prefix.- See Also:
-
-
Method Details
-
createValidator
@Nullable @Nullable Validator createValidator(@NotNull @NotNull ValidationContext context, @NotNull @NotNull ValidatorSettings settings) Creates a new validator for the given context.- Parameters:
context- the validation contextsettings- the validator settings- Returns:
- a new validator instance (lifecycle bound to the package outlined in context) or
nullin case there is no validation relevant for the given context
-
shouldValidateSubpackages
boolean shouldValidateSubpackages()Returns whether the validator should by default also called for subpackages.- Returns:
truein case the validation with this validator should also happen for subpackages (recursively), otherwisefalse
-
getId
Returns the validator ID. It should be unique i.e. not overlap between any two validators. To achieve that use the format<prefix>-<name>for every ID. Reserved prefixes are "jackrabbit" (used by all OOTB validators), "aem" and "sling". For custom validators use a company name as prefix. The name should not contain the string "validator". The id should only contain lower case characters.- Returns:
- the id of the validator returned by
createValidator(ValidationContext, ValidatorSettings)
-
getServiceRanking
int getServiceRanking()The service ranking will influence the order in which the validators will be called. In general: The higher the ranking the earlier it will be executed.- Returns:
- the service ranking
-