Skip to main content

antecedent_validate/
custom.rs

1//! Object-safe custom effect validators.
2//!
3//! SPDX-License-Identifier: MIT OR Apache-2.0
4
5use antecedent_core::ExecutionContext;
6
7use crate::common::{RefutationProblem, RefutationReport};
8use crate::error::ValidationError;
9
10/// Slow-path custom effect validator (Python / user callbacks).
11///
12/// Distinct from [`crate::Validator`] which uses associated types and is not dyn-safe.
13///
14/// Deliberately **not** sealed: object-safe extension for host languages (`PyO3`)
15/// and app-level hooks. Prefer [`crate::Validator`] for in-crate refuters.
16pub trait CustomEffectValidator: Send + Sync {
17    /// Stable name written into [`RefutationReport::refuter`].
18    fn name(&self) -> &str;
19
20    /// Run the check against a prepared refutation problem.
21    ///
22    /// # Errors
23    ///
24    /// Validation / applicability failures.
25    fn validate(
26        &self,
27        problem: &RefutationProblem<'_>,
28        ctx: &ExecutionContext,
29    ) -> Result<RefutationReport, ValidationError>;
30}