taskdn 0.1.0

Rust library for parsing, querying, and manipulating Taskdn task files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
//! Task entity and related types.

use super::{DateTimeValue, FileReference};
use crate::validation::ValidationWarning;
use chrono::NaiveDate;
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;

/// Status of a task.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[non_exhaustive]
pub enum TaskStatus {
    /// New task, needs triage.
    #[default]
    Inbox,
    /// Deprioritized, might do someday.
    Icebox,
    /// Ready to work on.
    Ready,
    /// Currently being worked on.
    InProgress,
    /// Waiting on something external.
    Blocked,
    /// Abandoned, won't be completed.
    Dropped,
    /// Successfully completed.
    Done,
}

impl TaskStatus {
    /// Returns true if this status represents a completed state (done or dropped).
    #[must_use]
    pub fn is_completed(&self) -> bool {
        matches!(self, Self::Done | Self::Dropped)
    }

    /// Returns true if this status represents an active state.
    ///
    /// Active means the task is not completed (done/dropped) and not in inbox/icebox.
    #[must_use]
    pub fn is_active(&self) -> bool {
        matches!(self, Self::Ready | Self::InProgress | Self::Blocked)
    }

    /// Returns the canonical string representation (lowercase, hyphenated).
    #[must_use]
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Inbox => "inbox",
            Self::Icebox => "icebox",
            Self::Ready => "ready",
            Self::InProgress => "in-progress",
            Self::Blocked => "blocked",
            Self::Dropped => "dropped",
            Self::Done => "done",
        }
    }
}

impl FromStr for TaskStatus {
    type Err = String;

    /// Parse from string (case-insensitive, handles "in-progress" and "in\_progress").
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().replace('_', "-").as_str() {
            "inbox" => Ok(Self::Inbox),
            "icebox" => Ok(Self::Icebox),
            "ready" => Ok(Self::Ready),
            "in-progress" => Ok(Self::InProgress),
            "blocked" => Ok(Self::Blocked),
            "dropped" => Ok(Self::Dropped),
            "done" => Ok(Self::Done),
            _ => Err(format!("invalid task status: {s}")),
        }
    }
}

impl std::fmt::Display for TaskStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

/// A parsed task file.
#[derive(Debug, Clone, PartialEq)]
pub struct Task {
    // Identity
    /// Absolute path to the task file.
    pub path: PathBuf,

    // Required frontmatter
    /// The task title.
    pub title: String,
    /// Current status of the task.
    pub status: TaskStatus,
    /// When the task was created.
    pub created_at: DateTimeValue,
    /// When the task was last updated.
    pub updated_at: DateTimeValue,

    // Optional frontmatter
    /// When the task was completed (set automatically when status becomes done/dropped).
    pub completed_at: Option<DateTimeValue>,
    /// When the task is due.
    pub due: Option<DateTimeValue>,
    /// Date the task is scheduled to be worked on.
    pub scheduled: Option<NaiveDate>,
    /// Date until which the task is deferred (hidden until this date).
    pub defer_until: Option<NaiveDate>,
    /// Reference to the project this task belongs to.
    pub project: Option<FileReference>,
    /// Reference to the area this task belongs to.
    pub area: Option<FileReference>,

    // Preserved content
    /// Markdown body (everything after frontmatter).
    pub body: String,
    /// Unknown frontmatter fields (preserved on write).
    pub extra: HashMap<String, serde_yaml::Value>,

    // Validation metadata
    /// Number of elements in the `projects` array (if used).
    /// `None` if `project` field was used instead of `projects` array.
    /// Used for validation - spec says exactly one project per task.
    pub projects_count: Option<usize>,
}

impl Task {
    /// Returns the filename without path (e.g., "my-task.md").
    #[must_use]
    pub fn filename(&self) -> &str {
        self.path.file_name().and_then(|n| n.to_str()).unwrap_or("")
    }

    /// Returns true if this task is in the archive subdirectory.
    #[must_use]
    pub fn is_archived(&self) -> bool {
        self.path.components().any(|c| c.as_os_str() == "archive")
    }

    /// Returns true if this task is "active" (not done, dropped, or archived).
    #[must_use]
    pub fn is_active(&self) -> bool {
        !self.status.is_completed() && !self.is_archived()
    }

    /// Validate the task against spec recommendations.
    ///
    /// Returns a list of warnings for spec violations. An empty list means
    /// the task fully complies with the specification.
    ///
    /// Checks performed:
    /// - `projects` array should have exactly one element (warns if >1)
    /// - Completed tasks (done/dropped) should have `completed-at` set
    #[must_use]
    pub fn validate(&self) -> Vec<ValidationWarning> {
        let mut warnings = Vec::new();

        // Check for multiple projects
        if let Some(count) = self.projects_count {
            if count > 1 {
                warnings.push(ValidationWarning::MultipleProjects { count });
            }
        }

        // Check for missing completed_at on completed tasks
        if self.status.is_completed() && self.completed_at.is_none() {
            warnings.push(ValidationWarning::MissingCompletedAt);
        }

        warnings
    }
}

/// Parsed task content without a file path.
///
/// Use this when parsing from a string rather than reading from disk.
#[derive(Debug, Clone, PartialEq)]
pub struct ParsedTask {
    /// The task title.
    pub title: String,
    /// Current status of the task.
    pub status: TaskStatus,
    /// When the task was created.
    pub created_at: DateTimeValue,
    /// When the task was last updated.
    pub updated_at: DateTimeValue,
    /// When the task was completed.
    pub completed_at: Option<DateTimeValue>,
    /// When the task is due.
    pub due: Option<DateTimeValue>,
    /// Date the task is scheduled to be worked on.
    pub scheduled: Option<NaiveDate>,
    /// Date until which the task is deferred.
    pub defer_until: Option<NaiveDate>,
    /// Reference to the project this task belongs to.
    pub project: Option<FileReference>,
    /// Reference to the area this task belongs to.
    pub area: Option<FileReference>,
    /// Markdown body.
    pub body: String,
    /// Unknown frontmatter fields.
    pub extra: HashMap<String, serde_yaml::Value>,
    /// Number of elements in the `projects` array (if used).
    pub projects_count: Option<usize>,
}

impl ParsedTask {
    /// Convert to a Task by associating with a file path.
    #[must_use]
    pub fn with_path(self, path: impl Into<PathBuf>) -> Task {
        Task {
            path: path.into(),
            title: self.title,
            status: self.status,
            created_at: self.created_at,
            updated_at: self.updated_at,
            completed_at: self.completed_at,
            due: self.due,
            scheduled: self.scheduled,
            defer_until: self.defer_until,
            project: self.project,
            area: self.area,
            body: self.body,
            extra: self.extra,
            projects_count: self.projects_count,
        }
    }

    /// Validate the parsed task against spec recommendations.
    ///
    /// Returns a list of warnings for spec violations. An empty list means
    /// the task fully complies with the specification.
    ///
    /// Checks performed:
    /// - `projects` array should have exactly one element (warns if >1)
    /// - Completed tasks (done/dropped) should have `completed-at` set
    #[must_use]
    pub fn validate(&self) -> Vec<ValidationWarning> {
        let mut warnings = Vec::new();

        // Check for multiple projects
        if let Some(count) = self.projects_count {
            if count > 1 {
                warnings.push(ValidationWarning::MultipleProjects { count });
            }
        }

        // Check for missing completed_at on completed tasks
        if self.status.is_completed() && self.completed_at.is_none() {
            warnings.push(ValidationWarning::MissingCompletedAt);
        }

        warnings
    }
}

/// Data for creating a new task.
///
/// Unlike `Task`, this doesn't include path, `created_at`, `updated_at`, or
/// `completed_at` (SDK sets these automatically).
#[derive(Debug, Clone, Default)]
pub struct NewTask {
    /// The task title (required).
    pub title: String,
    /// Initial status (defaults to Inbox).
    pub status: TaskStatus,
    /// Optional custom filename (generated from title if None).
    pub filename: Option<String>,
    /// When the task is due.
    pub due: Option<DateTimeValue>,
    /// Date the task is scheduled to be worked on.
    pub scheduled: Option<NaiveDate>,
    /// Date until which the task is deferred.
    pub defer_until: Option<NaiveDate>,
    /// Reference to the project this task belongs to.
    pub project: Option<FileReference>,
    /// Reference to the area this task belongs to.
    pub area: Option<FileReference>,
    /// Markdown body content.
    pub body: String,
    /// Additional frontmatter fields.
    pub extra: HashMap<String, serde_yaml::Value>,
}

impl NewTask {
    /// Create a new task with the given title. Status defaults to Inbox.
    #[must_use]
    pub fn new(title: impl Into<String>) -> Self {
        Self {
            title: title.into(),
            status: TaskStatus::Inbox,
            ..Default::default()
        }
    }

    /// Set the status.
    #[must_use]
    pub fn with_status(mut self, status: TaskStatus) -> Self {
        self.status = status;
        self
    }

    /// Set a custom filename.
    #[must_use]
    pub fn with_filename(mut self, filename: impl Into<String>) -> Self {
        self.filename = Some(filename.into());
        self
    }

    /// Set the due date/datetime.
    #[must_use]
    pub fn with_due(mut self, due: impl Into<DateTimeValue>) -> Self {
        self.due = Some(due.into());
        self
    }

    /// Set the scheduled date.
    #[must_use]
    pub fn with_scheduled(mut self, scheduled: NaiveDate) -> Self {
        self.scheduled = Some(scheduled);
        self
    }

    /// Set the defer until date.
    #[must_use]
    pub fn with_defer_until(mut self, defer_until: NaiveDate) -> Self {
        self.defer_until = Some(defer_until);
        self
    }

    /// Assign to a project.
    #[must_use]
    pub fn in_project(mut self, project: impl Into<FileReference>) -> Self {
        self.project = Some(project.into());
        self
    }

    /// Assign to an area.
    #[must_use]
    pub fn in_area(mut self, area: impl Into<FileReference>) -> Self {
        self.area = Some(area.into());
        self
    }

    /// Set the body content.
    #[must_use]
    pub fn with_body(mut self, body: impl Into<String>) -> Self {
        self.body = body.into();
        self
    }
}

/// Partial updates for a task.
///
/// Uses the double-Option pattern: `None` means "don't change",
/// `Some(None)` means "clear the field", `Some(Some(x))` means "set to x".
#[derive(Debug, Clone, Default)]
pub struct TaskUpdates {
    /// New title (None = don't change).
    pub title: Option<String>,
    /// New status (None = don't change).
    pub status: Option<TaskStatus>,
    /// New due date (None = don't change, Some(None) = clear, Some(Some(x)) = set).
    pub due: Option<Option<DateTimeValue>>,
    /// New scheduled date.
    pub scheduled: Option<Option<NaiveDate>>,
    /// New defer until date.
    pub defer_until: Option<Option<NaiveDate>>,
    /// New project reference.
    pub project: Option<Option<FileReference>>,
    /// New area reference.
    pub area: Option<Option<FileReference>>,
}

impl TaskUpdates {
    /// Create a new empty updates struct.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Set a new title.
    #[must_use]
    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = Some(title.into());
        self
    }

    /// Set a new status.
    #[must_use]
    pub fn status(mut self, status: TaskStatus) -> Self {
        self.status = Some(status);
        self
    }

    /// Set a new due date.
    #[must_use]
    pub fn due(mut self, due: impl Into<DateTimeValue>) -> Self {
        self.due = Some(Some(due.into()));
        self
    }

    /// Clear the due date.
    #[must_use]
    pub fn clear_due(mut self) -> Self {
        self.due = Some(None);
        self
    }

    /// Set a new scheduled date.
    #[must_use]
    pub fn scheduled(mut self, scheduled: NaiveDate) -> Self {
        self.scheduled = Some(Some(scheduled));
        self
    }

    /// Clear the scheduled date.
    #[must_use]
    pub fn clear_scheduled(mut self) -> Self {
        self.scheduled = Some(None);
        self
    }

    /// Set a new defer until date.
    #[must_use]
    pub fn defer_until(mut self, defer_until: NaiveDate) -> Self {
        self.defer_until = Some(Some(defer_until));
        self
    }

    /// Clear the defer until date.
    #[must_use]
    pub fn clear_defer_until(mut self) -> Self {
        self.defer_until = Some(None);
        self
    }

    /// Set a new project reference.
    #[must_use]
    pub fn project(mut self, project: impl Into<FileReference>) -> Self {
        self.project = Some(Some(project.into()));
        self
    }

    /// Clear the project reference.
    #[must_use]
    pub fn clear_project(mut self) -> Self {
        self.project = Some(None);
        self
    }

    /// Set a new area reference.
    #[must_use]
    pub fn area(mut self, area: impl Into<FileReference>) -> Self {
        self.area = Some(Some(area.into()));
        self
    }

    /// Clear the area reference.
    #[must_use]
    pub fn clear_area(mut self) -> Self {
        self.area = Some(None);
        self
    }

    /// Returns true if no updates are specified.
    #[must_use]
    pub fn is_empty(&self) -> bool {
        self.title.is_none()
            && self.status.is_none()
            && self.due.is_none()
            && self.scheduled.is_none()
            && self.defer_until.is_none()
            && self.project.is_none()
            && self.area.is_none()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    mod task_status {
        use super::*;

        #[test]
        fn parse_lowercase() {
            assert_eq!("inbox".parse::<TaskStatus>().unwrap(), TaskStatus::Inbox);
            assert_eq!("ready".parse::<TaskStatus>().unwrap(), TaskStatus::Ready);
            assert_eq!(
                "in-progress".parse::<TaskStatus>().unwrap(),
                TaskStatus::InProgress
            );
        }

        #[test]
        fn parse_case_insensitive() {
            assert_eq!("INBOX".parse::<TaskStatus>().unwrap(), TaskStatus::Inbox);
            assert_eq!("Ready".parse::<TaskStatus>().unwrap(), TaskStatus::Ready);
            assert_eq!(
                "IN-PROGRESS".parse::<TaskStatus>().unwrap(),
                TaskStatus::InProgress
            );
        }

        #[test]
        fn parse_underscore_variant() {
            assert_eq!(
                "in_progress".parse::<TaskStatus>().unwrap(),
                TaskStatus::InProgress
            );
        }

        #[test]
        fn parse_invalid() {
            assert!("invalid".parse::<TaskStatus>().is_err());
        }

        #[test]
        fn as_str_returns_canonical() {
            assert_eq!(TaskStatus::Inbox.as_str(), "inbox");
            assert_eq!(TaskStatus::InProgress.as_str(), "in-progress");
        }

        #[test]
        fn is_completed() {
            assert!(TaskStatus::Done.is_completed());
            assert!(TaskStatus::Dropped.is_completed());
            assert!(!TaskStatus::Ready.is_completed());
            assert!(!TaskStatus::Inbox.is_completed());
        }

        #[test]
        fn is_active() {
            assert!(TaskStatus::Ready.is_active());
            assert!(TaskStatus::InProgress.is_active());
            assert!(TaskStatus::Blocked.is_active());
            assert!(!TaskStatus::Inbox.is_active());
            assert!(!TaskStatus::Done.is_active());
        }
    }

    mod task {
        use super::*;
        use std::path::Path;

        fn sample_task(path: impl AsRef<Path>) -> Task {
            Task {
                path: path.as_ref().to_path_buf(),
                title: "Test Task".to_string(),
                status: TaskStatus::Ready,
                created_at: "2025-01-01".parse().unwrap(),
                updated_at: "2025-01-01".parse().unwrap(),
                completed_at: None,
                due: None,
                scheduled: None,
                defer_until: None,
                project: None,
                area: None,
                body: String::new(),
                extra: HashMap::new(),
                projects_count: None,
            }
        }

        #[test]
        fn filename_extracts_correctly() {
            let task = sample_task("/path/to/tasks/my-task.md");
            assert_eq!(task.filename(), "my-task.md");
        }

        #[test]
        fn is_archived_detects_archive_path() {
            let archived = sample_task("/path/to/tasks/archive/old-task.md");
            assert!(archived.is_archived());

            let not_archived = sample_task("/path/to/tasks/my-task.md");
            assert!(!not_archived.is_archived());
        }

        #[test]
        fn is_active_considers_status_and_archive() {
            let active = sample_task("/path/to/tasks/my-task.md");
            assert!(active.is_active());

            let mut done = sample_task("/path/to/tasks/done-task.md");
            done.status = TaskStatus::Done;
            assert!(!done.is_active());

            let archived = sample_task("/path/to/tasks/archive/old-task.md");
            assert!(!archived.is_active());
        }
    }

    mod new_task {
        use super::*;

        #[test]
        fn new_defaults_to_inbox() {
            let task = NewTask::new("Test");
            assert_eq!(task.status, TaskStatus::Inbox);
        }

        #[test]
        fn builder_pattern() {
            let task = NewTask::new("Test")
                .with_status(TaskStatus::Ready)
                .in_project("[[My Project]]")
                .with_body("Some content");

            assert_eq!(task.status, TaskStatus::Ready);
            assert!(task.project.is_some());
            assert_eq!(task.body, "Some content");
        }
    }

    mod task_updates {
        use super::*;

        #[test]
        fn empty_updates() {
            let updates = TaskUpdates::new();
            assert!(updates.is_empty());
        }

        #[test]
        fn with_title() {
            let updates = TaskUpdates::new().title("New Title");
            assert!(!updates.is_empty());
            assert_eq!(updates.title, Some("New Title".to_string()));
        }

        #[test]
        fn clear_due() {
            let updates = TaskUpdates::new().clear_due();
            assert_eq!(updates.due, Some(None));
        }

        #[test]
        fn set_due() {
            let due: DateTimeValue = "2025-06-01".parse().unwrap();
            let updates = TaskUpdates::new().due(due.clone());
            assert_eq!(updates.due, Some(Some(due)));
        }
    }

    mod validation {
        use super::*;
        use std::path::Path;

        fn sample_task(path: impl AsRef<Path>) -> Task {
            Task {
                path: path.as_ref().to_path_buf(),
                title: "Test Task".to_string(),
                status: TaskStatus::Ready,
                created_at: "2025-01-01".parse().unwrap(),
                updated_at: "2025-01-01".parse().unwrap(),
                completed_at: None,
                due: None,
                scheduled: None,
                defer_until: None,
                project: None,
                area: None,
                body: String::new(),
                extra: HashMap::new(),
                projects_count: None,
            }
        }

        #[test]
        fn valid_task_has_no_warnings() {
            let task = sample_task("/test/task.md");
            assert!(task.validate().is_empty());
        }

        #[test]
        fn single_project_has_no_warning() {
            let mut task = sample_task("/test/task.md");
            task.projects_count = Some(1);
            assert!(task.validate().is_empty());
        }

        #[test]
        fn multiple_projects_warns() {
            let mut task = sample_task("/test/task.md");
            task.projects_count = Some(3);

            let warnings = task.validate();
            assert_eq!(warnings.len(), 1);
            assert!(matches!(
                warnings[0],
                ValidationWarning::MultipleProjects { count: 3 }
            ));
        }

        #[test]
        fn done_task_without_completed_at_warns() {
            let mut task = sample_task("/test/task.md");
            task.status = TaskStatus::Done;

            let warnings = task.validate();
            assert_eq!(warnings.len(), 1);
            assert!(matches!(warnings[0], ValidationWarning::MissingCompletedAt));
        }

        #[test]
        fn dropped_task_without_completed_at_warns() {
            let mut task = sample_task("/test/task.md");
            task.status = TaskStatus::Dropped;

            let warnings = task.validate();
            assert_eq!(warnings.len(), 1);
            assert!(matches!(warnings[0], ValidationWarning::MissingCompletedAt));
        }

        #[test]
        fn done_task_with_completed_at_has_no_warning() {
            let mut task = sample_task("/test/task.md");
            task.status = TaskStatus::Done;
            task.completed_at = Some("2025-01-15".parse().unwrap());

            assert!(task.validate().is_empty());
        }

        #[test]
        fn multiple_warnings_accumulated() {
            let mut task = sample_task("/test/task.md");
            task.status = TaskStatus::Done;
            task.projects_count = Some(2);

            let warnings = task.validate();
            assert_eq!(warnings.len(), 2);
        }

        #[test]
        fn parsed_task_validate_works() {
            let parsed = ParsedTask {
                title: "Test".to_string(),
                status: TaskStatus::Done,
                created_at: "2025-01-01".parse().unwrap(),
                updated_at: "2025-01-01".parse().unwrap(),
                completed_at: None,
                due: None,
                scheduled: None,
                defer_until: None,
                project: None,
                area: None,
                body: String::new(),
                extra: HashMap::new(),
                projects_count: Some(2),
            };

            let warnings = parsed.validate();
            assert_eq!(warnings.len(), 2);
        }
    }
}