com.memority.toolkit.rule.api.ValidationRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toolkit-rule-api Show documentation
Show all versions of toolkit-rule-api Show documentation
This artifact provides the API classes that are necessary to implement the contracts of Memority configuration Rules.
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Toolkit API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.toolkit.rule.api;
import com.memority.toolkit.rule.api.context.Context;
import java.util.List;
/**
* A validation Rule is used to validate an input value against a business Rule, that can use the
* given Context as support.
*
* A validation Rule returns a {@link ValidationRuleResult} that encapsulates the validation
* success or failure.
*/
public interface ValidationRule extends Rule {
/**
* The input value is exposed through this key as {@value #KEY_VALUE}
*/
String KEY_VALUE = "VALUE";
@Override
default RuleType getRuleType() {
return RuleType.VALIDATION;
}
/**
* Run the Validation Rule on the given value
with the given context
and return
* an {@link ValidationRuleResult}.
*
* @param value the value to validate, maybe null
* @param context the execution context
* @return the validation result, never null
*/
ValidationRuleResult validate(Object value, Context context);
}