Skip to main content

icydb_schema/node/
validator.rs

1use crate::prelude::*;
2
3///
4/// Validator
5///
6
7#[derive(Clone, Debug, Serialize)]
8pub struct Validator {
9    def: Def,
10}
11
12impl Validator {
13    /// Creates a validator node from definition metadata.
14    #[must_use]
15    pub const fn new(def: Def) -> Self {
16        Self { def }
17    }
18
19    /// Returns the validator definition metadata.
20    #[must_use]
21    pub const fn def(&self) -> &Def {
22        &self.def
23    }
24}
25
26impl MacroNode for Validator {
27    fn as_any(&self) -> &dyn std::any::Any {
28        self
29    }
30}
31
32impl ValidateNode for Validator {}
33
34impl VisitableNode for Validator {
35    fn route_key(&self) -> String {
36        self.def().path()
37    }
38
39    fn drive<V: Visitor>(&self, v: &mut V) {
40        self.def().accept(v);
41    }
42}