File: allow_unvalidated.rs

package info (click to toggle)
rust-garde 0.22.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 940 kB
  • sloc: makefile: 2
file content (33 lines) | stat: -rw-r--r-- 500 bytes parent folder | download | duplicates (2)
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
use super::util;

#[allow(dead_code)]
#[derive(Debug, garde::Validate)]
#[garde(allow_unvalidated)]
struct Test<'a> {
    #[garde(ascii)]
    field: &'a str,

    unvalidated: &'a str,
}

#[test]
fn ascii_valid() {
    util::check_ok(
        &[Test {
            field: "a!0_~",
            unvalidated: "",
        }],
        &(),
    )
}

#[test]
fn ascii_invalid() {
    util::check_fail!(
        &[Test {
            field: "😂",
            unvalidated: "",
        }],
        &()
    )
}