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
//! This module contains structures and traits for performing validation checks.
use crate;
/// A trait for performing validation checks and handling validation-related errors.
///
/// This trait provides methods to:
/// - Create a new validation error instance from an error store.
/// - Collect and validate errors, returning a result depending on whether any errors are found.
///
/// # Associated Types
/// - `Self`: The concrete type that implements the `ValidationCheck` trait, which represents validation errors.
///
/// # Required Methods
///
/// ## `validate_new`
///
/// Creates a new instance of the implementing type using a provided `ValidateErrorStore`.
///
/// ### Parameters
/// - `messages`: An instance of `ValidateErrorStore` that holds validation error information.
///
/// ### Returns
/// - `Self`: A new instance of the implementing type initialized with the given error messages.
///
///
/// # Provided Methods
///
/// ## `validate_check`
///
/// Performs a validation check using a `ValidateErrorCollector`. If the collector contains errors,
/// it returns an error wrapped in the implementing type; otherwise, it succeeds with `Ok(())`.
///
/// ### Parameters
/// - `messages`: An instance of `ValidateErrorCollector` that holds collected validation errors.
///
/// ### Returns
/// - `Ok(())`: If the collector does not contain any errors.
/// - `Err(Self)`: If the collector contains errors, an error instance of the implementing type is returned.
///
/// The default implementation checks if the provided `messages` is empty. If it is empty, it returns an `Ok(())`.
/// Otherwise, it converts the messages into a `ValidateErrorStore` and creates a new validation error instance using `validate_new`.
///
///