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
//! Length validation.
//!
//! ```rust
//! #[derive(garde::Validate)]
//! struct Test {
//! #[garde(length(min=1, max=100))]
//! v: String,
//! }
//! ```
//!
//! The concept of "length" is somewhat complicated, especially for strings. Therefore, the `length` rule currently supports different modes:
//! - [`Simple`][simple::Simple], which is the default
//! - [`Bytes`][bytes::Bytes]
//! - [`Chars`][chars::Chars]
//! - [`Graphemes`][graphemes::Graphemes]
//! - [`Utf16CodeUnits`][utf16::Utf16CodeUnits]
//!
//! The mode is configured on the `length` rule:
//! ```rust
//! #[derive(garde::Validate)]
//! struct Test {
//! #[garde(
//! length(graphemes, min=1, max=25),
//! length(bytes, min=1, max=100),
//! )]
//! v: String,
//! }
//! ```
//!
//! Here's what implementing the trait for a custom string-like type might look like:
//! ```rust
//! #[repr(transparent)]
//! struct MyString(String);
//!
//! impl garde::rules::length::HasSimpleLength for MyString {
//! fn length(&self) -> usize {
//! self.0.len()
//! }
//! }
//! ```
//!
//! See each trait for more information.
//!
pub use HasBytes;
pub use HasChars;
pub use HasGraphemes;
pub use HasSimpleLength;
pub use HasUtf16CodeUnits;
use crateError;