|
1 | 1 | use chrono::{DateTime, Utc}; |
2 | 2 | use serde::{Deserialize, Serialize}; |
3 | 3 | use ts_rs::TS; |
4 | | -use validator::Validate; |
5 | 4 |
|
6 | 5 | /// Query parameters for searching on a date time |
7 | | -#[derive(Deserialize, Serialize, TS, Debug, Validate, Clone)] |
| 6 | +#[derive(Deserialize, Serialize, TS, Debug, Clone)] |
8 | 7 | #[serde(rename_all = "camelCase")] |
9 | 8 | #[ts(export, rename = "DateTimeQuery")] |
10 | | -pub struct DateTimeQuery { |
11 | | - /// Optional "equal" query (UTC) |
12 | | - #[ts(type = "Date", optional)] |
13 | | - pub eq: Option<DateTime<Utc>>, |
| 9 | +pub enum DateTimeQuery { |
| 10 | + /// "equal" query (UTC) |
| 11 | + #[ts(type = "Date")] |
| 12 | + Eq(DateTime<Utc>), |
14 | 13 |
|
15 | | - /// Optional "greater than or equal" query (UTC) |
16 | | - #[ts(type = "Date", optional)] |
17 | | - pub gte: Option<DateTime<Utc>>, |
| 14 | + /// "greater than or equal" query (UTC) |
| 15 | + #[ts(type = "Date")] |
| 16 | + Gte(DateTime<Utc>), |
18 | 17 |
|
19 | | - /// Optional "less than or equal" query (UTC) |
20 | | - #[ts(type = "Date", optional)] |
21 | | - pub lte: Option<DateTime<Utc>>, |
| 18 | + /// "less than or equal" query (UTC) |
| 19 | + #[ts(type = "Date")] |
| 20 | + Lte(DateTime<Utc>), |
22 | 21 |
|
23 | | - /// Optional "greater than" query (UTC) |
| 22 | + /// "greater than" query (UTC) |
24 | 23 | /// This is exclusive of the value |
25 | | - #[ts(type = "Date", optional)] |
26 | | - pub gt: Option<DateTime<Utc>>, |
| 24 | + #[ts(type = "Date")] |
| 25 | + Gt(DateTime<Utc>), |
27 | 26 |
|
28 | | - /// Optional "less than" query (UTC) |
| 27 | + /// "less than" query (UTC) |
29 | 28 | /// This is exclusive of the value |
30 | | - #[ts(type = "Date", optional)] |
31 | | - pub lt: Option<DateTime<Utc>>, |
| 29 | + #[ts(type = "Date")] |
| 30 | + Lt(DateTime<Utc>), |
32 | 31 | } |
0 commit comments