Skip to main content

nominal_api/conjure/objects/scout/webhook/template/api/
validation_error.rs

1/// A validation error with optional location information
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct ValidationError {
17    #[builder(into)]
18    #[serde(rename = "message")]
19    message: String,
20    #[builder(default, into)]
21    #[serde(rename = "line", skip_serializing_if = "Option::is_none", default)]
22    line: Option<i32>,
23    #[builder(default, into)]
24    #[serde(rename = "column", skip_serializing_if = "Option::is_none", default)]
25    column: Option<i32>,
26}
27impl ValidationError {
28    /// Constructs a new instance of the type.
29    #[inline]
30    pub fn new(message: impl Into<String>) -> Self {
31        Self::builder().message(message).build()
32    }
33    /// Error message
34    #[inline]
35    pub fn message(&self) -> &str {
36        &*self.message
37    }
38    /// Line number where error occurred
39    #[inline]
40    pub fn line(&self) -> Option<i32> {
41        self.line.as_ref().map(|o| *o)
42    }
43    /// Column number where error occurred
44    #[inline]
45    pub fn column(&self) -> Option<i32> {
46        self.column.as_ref().map(|o| *o)
47    }
48}