-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from Rolv-Apneseth/support-equal-for-length
- Loading branch information
Showing
17 changed files
with
397 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
garde/tests/rules/snapshots/rules__rules__length__min_max_equal_length_invalid.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
source: garde/tests/./rules/length.rs | ||
expression: snapshot | ||
--- | ||
MinMaxEqual { | ||
min_max: "", | ||
equal: "", | ||
} | ||
equal: length is lower than 2 | ||
min_max: length is lower than 2 | ||
|
||
MinMaxEqual { | ||
min_max: "b", | ||
equal: "b", | ||
} | ||
equal: length is lower than 2 | ||
min_max: length is lower than 2 | ||
|
||
MinMaxEqual { | ||
min_max: "bbb", | ||
equal: "bbb", | ||
} | ||
equal: length is greater than 2 | ||
min_max: length is greater than 2 |
30 changes: 30 additions & 0 deletions
30
garde/tests/rules/snapshots/rules__rules__range__exact_length_invalid.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
source: garde/tests/./rules/range.rs | ||
expression: snapshot | ||
--- | ||
Exact { | ||
field: 0, | ||
inner: [ | ||
0, | ||
], | ||
} | ||
field: lower than 2 | ||
inner[0]: lower than 2 | ||
|
||
Exact { | ||
field: 1, | ||
inner: [ | ||
1, | ||
], | ||
} | ||
field: lower than 2 | ||
inner[0]: lower than 2 | ||
|
||
Exact { | ||
field: 3, | ||
inner: [ | ||
3, | ||
], | ||
} | ||
field: greater than 2 | ||
inner[0]: greater than 2 |
24 changes: 24 additions & 0 deletions
24
garde/tests/rules/snapshots/rules__rules__range__min_max_equal_length_invalid.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
source: garde/tests/./rules/range.rs | ||
expression: snapshot | ||
--- | ||
MinMaxEqual { | ||
min_max: 0, | ||
equal: 0, | ||
} | ||
equal: lower than 40 | ||
min_max: lower than 40 | ||
|
||
MinMaxEqual { | ||
min_max: 39, | ||
equal: 39, | ||
} | ||
equal: lower than 40 | ||
min_max: lower than 40 | ||
|
||
MinMaxEqual { | ||
min_max: 41, | ||
equal: 41, | ||
} | ||
equal: greater than 40 | ||
min_max: greater than 40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(dead_code)] | ||
|
||
#[derive(garde::Validate)] | ||
struct Test<'a> { | ||
#[garde(length(max = 1, equal = 10))] | ||
max_equal: &'a str, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
garde/tests/ui/compile-fail/length_bad_equal_combined_max.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: no `min` or `max` allowed if using `equal` | ||
--> tests/ui/compile-fail/length_bad_equal_combined_max.rs | ||
| | ||
| #[garde(length(max = 1, equal = 10))] | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(dead_code)] | ||
|
||
#[derive(garde::Validate)] | ||
struct Test<'a> { | ||
#[garde(length(min = 1, equal = 10))] | ||
min_equal: &'a str, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
garde/tests/ui/compile-fail/length_bad_equal_combined_min.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: no `min` or `max` allowed if using `equal` | ||
--> tests/ui/compile-fail/length_bad_equal_combined_min.rs | ||
| | ||
| #[garde(length(min = 1, equal = 10))] | ||
| ^^^ |
9 changes: 9 additions & 0 deletions
9
garde/tests/ui/compile-fail/length_bad_equal_combined_min_max.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(dead_code)] | ||
|
||
#[derive(garde::Validate)] | ||
struct Test<'a> { | ||
#[garde(length(min = 1, max = 1, equal = 10))] | ||
min_max_equal: &'a str, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
garde/tests/ui/compile-fail/length_bad_equal_combined_min_max.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: no `min` or `max` allowed if using `equal` | ||
--> tests/ui/compile-fail/length_bad_equal_combined_min_max.rs | ||
| | ||
| #[garde(length(min = 1, max = 1, equal = 10))] | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.