1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// =============================================================================
// Copyright (c) 2025 - 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Adapter from text validators that consume dependency context.
use Error;
use Arc;
use BoundValidationContext;
use DependencySpec;
use PreparedValidator;
use ContextualTextValidatorAdapter;
use crateValidator;
use crateViolationDraft;
/// Prepares a text validator that reads its declared dependency slots.
///
/// The adapter passes the supplied [`BoundValidationContext`] directly to the
/// typed validator. When execution goes through [`super::BoundValidator`],
/// that boundary checks dependency count, shape, optionality, and paths before
/// invoking the adapter. The returned adapter does not validate the declared
/// dependency contract itself. Callers invoking [`PreparedValidator::validate`]
/// directly must supply a context satisfying
/// [`PreparedValidator::dependency_specs`]. Domain errors are converted with
/// `map_error`; callers must keep raw input out of the resulting draft.
///
/// # Type Parameters
///
/// - `V`: Text validator implementing the context-aware [`Validator`] contract.
/// - `E`: Its static domain error type, created and mapped within the
/// synchronous call, so it need not be `Send` or `Sync`.
/// - `M`: Mapper from the domain error to a safe violation draft.
///
/// # Panics
///
/// This function does not panic. A non-text erased input is returned as an
/// execution error by the prepared adapter.
///
/// # Parameters
///
/// - `dependencies`: Static dependency slots declared in execution order.
/// - `validator`: Thread-safe validator invoked with checked text and context.
/// - `map_error`: Converts a domain error to safe violation metadata.
///
/// # Returns
///
/// A shared prepared adapter for the supplied validator and mapper.