1use std::fmt;
6use std::ops::Deref;
7
8pub mod data_permission;
9pub mod dynamic_filter;
10pub mod dynamic_sql;
11pub mod entity_graph;
12pub mod find_with_related;
13pub mod hydration_plugin;
14pub mod join_dsl;
15pub mod json_query;
16pub mod lambda;
17pub mod query;
18pub mod queryable;
19pub mod quick_query;
20pub mod typed;
21pub mod typed_ast;
22
23pub use data_permission::*;
24pub use dynamic_filter::*;
25pub use dynamic_sql::*;
26pub use entity_graph::*;
27pub use find_with_related::*;
28pub use hydration_plugin::*;
29pub use join_dsl::*;
30pub use json_query::*;
31pub use lambda::*;
32pub use query::*;
33pub use queryable::*;
34pub use quick_query::*;
35pub use typed::*;
36pub use typed_ast::*;
37
38#[derive(Debug, Clone, PartialEq, Default)]
60pub struct ValidationError(Vec<sz_orm_sql_validator::SqlValidationError>);
61
62impl Deref for ValidationError {
63 type Target = Vec<sz_orm_sql_validator::SqlValidationError>;
64 fn deref(&self) -> &Self::Target {
65 &self.0
66 }
67}
68
69impl From<sz_orm_sql_validator::SqlValidationError> for ValidationError {
70 fn from(e: sz_orm_sql_validator::SqlValidationError) -> Self {
71 Self(vec![e])
72 }
73}
74
75impl From<Vec<sz_orm_sql_validator::SqlValidationError>> for ValidationError {
76 fn from(v: Vec<sz_orm_sql_validator::SqlValidationError>) -> Self {
77 Self(v)
78 }
79}
80
81impl fmt::Display for ValidationError {
82 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
83 if self.0.len() == 1 {
84 write!(f, "{}", self.0[0])
85 } else {
86 write!(f, "{} validation errors: ", self.0.len())?;
87 for (i, e) in self.0.iter().enumerate() {
88 if i > 0 {
89 write!(f, "; ")?;
90 }
91 write!(f, "{}", e)?;
92 }
93 Ok(())
94 }
95 }
96}
97
98impl std::error::Error for ValidationError {}