T - The parameter handler@FunctionalInterface
public interface ParameterValidator<A extends CommandActor,T>
ParameterTypes.
Validators work on subclasses as well. For example, we can write a validator to validate
a custom @Range(min, max) annotation for numbers:
{@code
public enum RangeValidator implements ParameterValidator {
INSTANCE; | Modifier and Type | Method and Description |
|---|---|
void |
validate(A actor,
T value,
@NotNull ParameterNode<A,T> parameter,
@NotNull Lamp<A> lamp)
Validates the specified value that was passed to a parameter.
|
void validate(@NotNull
A actor,
T value,
@NotNull
@NotNull ParameterNode<A,T> parameter,
@NotNull
@NotNull Lamp<A> lamp)
Ideally, a validator will want to throw an exception when the parameter is
not valid, and then further handled with CommandExceptionHandler.
value - The parameter value. May or may not be null, depending on the resolver.parameter - The parameter that will take this valueactor - The command actor