Skip to main content

vld/primitives/
any.rs

1use serde_json::Value;
2
3use crate::error::VldError;
4use crate::schema::VldSchema;
5
6/// Schema that accepts any JSON value. Created via [`vld::any()`](crate::any).
7#[derive(Clone, Copy)]
8pub struct ZAny;
9
10impl ZAny {
11    pub fn new() -> Self {
12        Self
13    }
14}
15
16impl Default for ZAny {
17    fn default() -> Self {
18        Self::new()
19    }
20}
21
22impl ZAny {
23    /// Generate a JSON Schema representation (empty schema = any).
24    ///
25    /// Requires the `openapi` feature.
26    #[cfg(feature = "openapi")]
27    pub fn to_json_schema(&self) -> serde_json::Value {
28        serde_json::json!({})
29    }
30}
31
32impl VldSchema for ZAny {
33    type Output = Value;
34
35    fn parse_value(&self, value: &Value) -> Result<Value, VldError> {
36        Ok(value.clone())
37    }
38}