Skip to main content

artifacts/models/
validation_error.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5#[cfg_attr(feature = "specta", derive(specta::Type))]
6pub struct ValidationError {
7    #[serde(rename = "loc")]
8    pub loc: Vec<models::ValidationErrorLocInner>,
9    #[serde(rename = "msg")]
10    pub msg: String,
11    #[serde(rename = "type")]
12    pub r#type: String,
13    #[serde(
14        rename = "input",
15        default,
16        with = "::serde_with::rust::double_option",
17        skip_serializing_if = "Option::is_none"
18    )]
19    #[cfg_attr(feature = "specta", specta(type = Option<Option<specta_util::Unknown>>))]
20    pub input: Option<Option<serde_json::Value>>,
21    #[serde(rename = "ctx", skip_serializing_if = "Option::is_none")]
22    #[cfg_attr(feature = "specta", specta(type = Option<specta_util::Unknown>))]
23    pub ctx: Option<serde_json::Value>,
24}
25
26impl ValidationError {
27    pub fn new(
28        loc: Vec<models::ValidationErrorLocInner>,
29        msg: String,
30        r#type: String,
31    ) -> ValidationError {
32        ValidationError {
33            loc,
34            msg,
35            r#type,
36            input: None,
37            ctx: None,
38        }
39    }
40}