| 1 |
//! Validator for `format` keyword. |
| 2 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 3 |
netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#, Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#}, |
| 4 |
strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#, |
| 5 |
syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#, |
| 6 |
}; |
| 7 |
|
| 8 |
use email_addressrust-analyzer cargo email_address 0.2.9 crate/::EmailAddressrust-analyzer cargo email_address 0.2.9 EmailAddress#; |
| 9 |
use fancy_regexrust-analyzer cargo fancy-regex 0.11.0 crate/::Regexrust-analyzer cargo fancy-regex 0.11.0 Regex#; |
| 10 |
use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{Maprust-analyzer cargo serde_json 1.0.145 map/Map#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 11 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#; |
| 12 |
use unicode_general_categoryrust-analyzer cargo unicode-general-category 1.1.0 crate/::{get_general_categoryrust-analyzer cargo unicode-general-category 1.1.0 category/get_general_category()., GeneralCategoryrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#}; |
| 13 |
use uuid_simdrust-analyzer cargo uuid-simd 0.8.0 crate/::{parse_hyphenatedrust-analyzer cargo uuid-simd 0.8.0 parse_hyphenated()., Outrust-analyzer cargo outref 0.5.2 Out#}; |
| 14 |
|
| 15 |
use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 16 |
compilerrust-analyzer cargo jsonschema 0.37.4 compiler/, ecmarust-analyzer cargo jsonschema 0.37.4 ecma/, |
| 17 |
errorrust-analyzer cargo jsonschema 0.37.4 error/::ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, |
| 18 |
keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 19 |
pathsrust-analyzer cargo jsonschema 0.37.4 paths/::{LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#}, |
| 20 |
threadrust-analyzer cargo jsonschema 0.37.4 thread/::ThreadBoundrust-analyzer cargo jsonschema 0.37.4 thread/ThreadBound#, |
| 21 |
typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#, |
| 22 |
validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#}, |
| 23 |
Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#, |
| 24 |
}; |
| 25 |
|
| 26 |
static URI_TEMPLATE_RErust-analyzer cargo jsonschema 0.37.4 keywords/format/URI_TEMPLATE_RE.: LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#<Regexrust-analyzer cargo fancy-regex 0.11.0 Regex#> = LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/impl#[`LazyLock<T, F>`]new().(|| { |
| 27 |
Regexrust-analyzer cargo fancy-regex 0.11.0 Regex#::newrust-analyzer cargo fancy-regex 0.11.0 impl#[Regex]new().( |
| 28 |
r#"^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*})*\z"# |
| 29 |
) |
| 30 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Is a valid regex") |
| 31 |
}); |
| 32 |
|
| 33 |
fn is_valid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer().(pointer: &str) -> bool { |
| 34 |
if pointer.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 35 |
// An empty string is a valid JSON Pointer |
| 36 |
return true; |
| 37 |
} |
| 38 |
|
| 39 |
let mut chars = pointer.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().(); |
| 40 |
|
| 41 |
// The first character must be a '/' |
| 42 |
if chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('/') { |
| 43 |
return false; |
| 44 |
} |
| 45 |
is_valid_json_pointer_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer_impl().(chars) |
| 46 |
} |
| 47 |
|
| 48 |
fn is_valid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_relative_json_pointer().(s: &str) -> bool { |
| 49 |
let mut chars = s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().(); |
| 50 |
|
| 51 |
// Parse the non-negative integer part |
| 52 |
match chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() { |
| 53 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('0') => { |
| 54 |
// If it starts with '0', it must be followed by '#' or '/' |
| 55 |
match chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() { |
| 56 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('#') => chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().(), |
| 57 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('/') => is_valid_json_pointer_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer_impl().(chars), |
| 58 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => true, |
| 59 |
_ => false, |
| 60 |
} |
| 61 |
} |
| 62 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) if c.is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_digit().() => { |
| 63 |
// Parse the rest of the integer |
| 64 |
while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() { |
| 65 |
match c { |
| 66 |
'#' => return chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().(), |
| 67 |
'/' => return is_valid_json_pointer_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer_impl().(chars), |
| 68 |
c if c.is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_digit().() => {} |
| 69 |
_ => return false, |
| 70 |
} |
| 71 |
} |
| 72 |
// Valid if it's just a number |
| 73 |
true |
| 74 |
} |
| 75 |
_ => false, |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
#[inline] |
| 80 |
fn is_valid_json_pointer_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer_impl().<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = char>>(chars: I) -> bool { |
| 81 |
let mut escaped = false; |
| 82 |
for c in chars { |
| 83 |
match c { |
| 84 |
// '/' is only allowed as a separator between reference tokens |
| 85 |
'/' if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().escaped => escaped = false, |
| 86 |
'~' if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().escaped => escaped = true, |
| 87 |
'0' | '1' if escaped => escaped = false, |
| 88 |
// These ranges cover all allowed unescaped characters |
| 89 |
'\x00'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\x2E' | '\x30'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\x7D' | '\x7F'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{10FFFF}' if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().escaped => {} |
| 90 |
// Any other character or combination is invalid |
| 91 |
_ => return false, |
| 92 |
} |
| 93 |
} |
| 94 |
// If we end in an escaped state, it's invalid |
| 95 |
!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().escaped |
| 96 |
} |
| 97 |
|
| 98 |
fn is_valid_daterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_date().(date: &str) -> bool { |
| 99 |
if date.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().10 { |
| 100 |
return false; |
| 101 |
} |
| 102 |
|
| 103 |
let bytes = date.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 104 |
|
| 105 |
// Check format: YYYY-MM-DD |
| 106 |
if bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'-' || bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().7]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'-' { |
| 107 |
return false; |
| 108 |
} |
| 109 |
|
| 110 |
// Parse year (YYYY) |
| 111 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(year) = parse_four_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_four_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 112 |
return false; |
| 113 |
}; |
| 114 |
|
| 115 |
// Parse month (MM) |
| 116 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(month) = parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 117 |
return false; |
| 118 |
}; |
| 119 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#12).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(&month) { |
| 120 |
return false; |
| 121 |
} |
| 122 |
|
| 123 |
// Parse day (DD) |
| 124 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(day) = parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 125 |
return false; |
| 126 |
}; |
| 127 |
if day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 { |
| 128 |
return false; |
| 129 |
} |
| 130 |
|
| 131 |
// Check day validity |
| 132 |
match month { |
| 133 |
1 | 3 | 5 | 7 | 8 | 10 | 12 => day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().31, |
| 134 |
4 | 6 | 9 | 11 => day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().30, |
| 135 |
2 => { |
| 136 |
if is_leap_yearrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_leap_year().(year) { |
| 137 |
day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().29 |
| 138 |
} else { |
| 139 |
day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().28 |
| 140 |
} |
| 141 |
} |
| 142 |
_ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("Month value is checked above"), |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
#[inline] |
| 147 |
fn is_leap_yearrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_leap_year().(year: u16) -> bool { |
| 148 |
(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 && year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().100 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().0) || (year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Rem<Self>`]rem().400 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0) |
| 149 |
} |
| 150 |
|
| 151 |
#[inline] |
| 152 |
fn parse_four_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_four_digits().(bytes: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u16> { |
| •153 |
// Little-endian layout: bytes[0] lands in the lowest byte of the u32. |
| 154 |
// Check if all bytes are ASCII digits |
| •155 |
let value = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().([bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().]); |
| 156 |
let sub = value.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_sub().(0x3030_3030); |
| 157 |
if sub.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(0x0606_0606) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0xF0F0_F0F0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 { |
| 158 |
return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 159 |
} |
| •160 |
let val = (sub rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x0F0F_0F0F).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(2561) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().8; |
| 161 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(((val rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x00FF_00FF).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(6_553_601) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().16) as u16) |
| 162 |
} |
| 163 |
|
| 164 |
#[inline] |
| 165 |
fn parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(bytes: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| •166 |
// Little-endian layout: bytes[0] lands in the low byte of the u16. |
| 167 |
// Check if all bytes are ASCII digits |
| 168 |
let value = u16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_le_bytes().([bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().]); |
| 169 |
let sub = value.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]wrapping_sub().(0x3030); |
| 170 |
if sub.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]wrapping_add().(0x0606) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().0xF0F0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().0 { |
| 171 |
return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 172 |
} |
| •173 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(((sub rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().0x0F0F).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]wrapping_mul().(2561) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr().8) as u8) |
| 174 |
} |
| 175 |
|
| 176 |
macro_rules! handle_offsetrust-analyzer cargo jsonschema 0.37.4 keywords/format/handle_offset! { |
| 177 |
($sign:tt, $i:ident, $bytes:expr, $hour:expr, $minute:expr, $second:expr) => {{ |
| 178 |
if $bytes.len() - $i != 6 { |
| 179 |
return false; |
| 180 |
} |
| 181 |
$i += 1; |
| 182 |
if $bytes[$i + 2] != b':' { |
| 183 |
return false; |
| 184 |
} |
| 185 |
let Some(offset_hh) = parse_two_digits(&$bytes[$i..$i + 2]) else { |
| 186 |
return false; |
| 187 |
}; |
| 188 |
let Some(offset_mm) = parse_two_digits(&$bytes[$i + 3..$i + 5]) else { |
| 189 |
return false; |
| 190 |
}; |
| 191 |
if offset_hh > 23 || offset_mm > 59 { |
| 192 |
return false; |
| 193 |
} |
| 194 |
|
| 195 |
if $second == 60 { |
| 196 |
let mut utc_hh = i16::from($hour); |
| 197 |
let mut utc_mm = i16::from($minute); |
| 198 |
let offset_hh = i16::from(offset_hh); |
| 199 |
let offset_mm = i16::from(offset_mm); |
| 200 |
|
| 201 |
// Apply offset based on the sign (+ or -) |
| 202 |
utc_hh $sign offset_hh; |
| 203 |
utc_mm $sign offset_mm; |
| 204 |
|
| 205 |
// Adjust for minute overflow/underflow |
| 206 |
utc_hh += utc_mm / 60; |
| 207 |
utc_mm %= 60; |
| 208 |
if utc_mm < 0 { |
| 209 |
utc_mm += 60; |
| 210 |
utc_hh -= 1; |
| 211 |
} |
| 212 |
|
| 213 |
// Adjust for hour overflow/underflow |
| 214 |
utc_hh = (utc_hh + 24) % 24; |
| 215 |
utc_hh == 23 && utc_mm == 59 |
| 216 |
} else { |
| 217 |
true |
| 218 |
} |
| 219 |
}}; |
| 220 |
} |
| 221 |
|
| 222 |
fn is_valid_timerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_time().(time: &str) -> bool { |
| 223 |
let bytes = time.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 224 |
let len = bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 225 |
|
| 226 |
if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().9 { |
| 227 |
// Minimum valid time is "HH:MM:SSZ" |
| 228 |
return false; |
| 229 |
} |
| 230 |
|
| 231 |
// Check HH:MM:SS format |
| 232 |
if bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b':' || bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().5]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b':' { |
| 233 |
return false; |
| 234 |
} |
| 235 |
|
| 236 |
// Parse hour (HH) |
| 237 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hour) = parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 238 |
return false; |
| 239 |
}; |
| 240 |
// Parse minute (MM) |
| 241 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(minute) = parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 242 |
return false; |
| 243 |
}; |
| 244 |
// Parse second (SS) |
| 245 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(second) = parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().6..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) else { |
| 246 |
return false; |
| 247 |
}; |
| 248 |
|
| 249 |
if hour rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().23 || minute rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().59 || second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().60 { |
| 250 |
return false; |
| 251 |
} |
| 252 |
|
| 253 |
let mut i = 8; |
| 254 |
|
| 255 |
// Check fractional seconds |
| 256 |
if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len && bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'.' { |
| 257 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 258 |
let mut has_digit = false; |
| 259 |
while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len && bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_digit().() { |
| 260 |
has_digit = true; |
| 261 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 262 |
} |
| 263 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_digit { |
| 264 |
return false; |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
// Check offset |
| 269 |
if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().len { |
| 270 |
return false; |
| 271 |
} |
| 272 |
|
| 273 |
match bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 274 |
b'Z' | b'z' => i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 && (second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().60 || (hour rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().23 && minute rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().59)), |
| 275 |
b'+' => handle_offsetrust-analyzer cargo jsonschema 0.37.4 keywords/format/handle_offset!!(-=, i, bytes, hour, minute, second), |
| 276 |
b'-' => handle_offsetrust-analyzer cargo jsonschema 0.37.4 keywords/format/handle_offset!!(+=, i, bytes, hour, minute, second), |
| 277 |
_ => false, |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
fn is_valid_datetimerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_datetime().(datetime: &str) -> bool { |
| 282 |
// Find the position of 'T' or 't' separator |
| 283 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t_pos) = datetime.bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Bytes<'_>`][Iterator]position().(|b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'T' || b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b't') else { |
| 284 |
return false; |
| 285 |
}; |
| 286 |
|
| 287 |
// Split the string into date and time parts |
| 288 |
let (date_part, time_part) = datetime.split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(t_pos); |
| 289 |
|
| 290 |
is_valid_daterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_date().(date_part) && is_valid_timerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_time().(&time_part[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 291 |
} |
| 292 |
|
| 293 |
fn is_valid_email_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_email_impl().<F>(email: &str, is_valid_hostname_impl: F) -> bool |
| 294 |
where |
| 295 |
F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&str) -> bool, |
| 296 |
{ |
| 297 |
if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(parsed) = EmailAddressrust-analyzer cargo email_address 0.2.9 EmailAddress#::from_strrust-analyzer cargo email_address 0.2.9 impl#[EmailAddress][FromStr]from_str().(email) { |
| 298 |
let domain = parsed.domainrust-analyzer cargo email_address 0.2.9 impl#[EmailAddress]domain().(); |
| 299 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(domain) = domain.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('[').and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|d| d.strip_suffixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_suffix().(']')) { |
| 300 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(domain) = domain.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("IPv6:") { |
| 301 |
domain.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#>().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 302 |
} else { |
| 303 |
domain.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#>().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 304 |
} |
| 305 |
} else { |
| 306 |
is_valid_hostname_impl(domain) |
| 307 |
} |
| 308 |
} else { |
| 309 |
false |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
fn is_valid_emailrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_email().(email: &str) -> bool { |
| 314 |
is_valid_email_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_email_impl().(email, is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().) |
| 315 |
} |
| 316 |
|
| 317 |
fn is_valid_idn_emailrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_email().(email: &str) -> bool { |
| 318 |
is_valid_email_implrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_email_impl().(email, is_valid_idn_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_hostname().) |
| 319 |
} |
| 320 |
|
| 321 |
fn is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().(hostname: &str) -> bool { |
| 322 |
const VALID_CHARSrust-analyzer cargo jsonschema 0.37.4 keywords/format/VALID_CHARS.: [bool; 256] = { |
| 323 |
let mut table = [false; 256]; |
| 324 |
let mut byte: u8 = 0; |
| 325 |
while byte rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().255 { |
| 326 |
table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().byte as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(byte, b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-'); |
| 327 |
byte rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1; |
| 328 |
} |
| 329 |
// Handle byte 255 separately to avoid overflow |
| 330 |
table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().255]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(255u8, b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-'); |
| 331 |
table |
| 332 |
}; |
| 333 |
|
| 334 |
fn label_allows_punycoderust-analyzer cargo jsonschema 0.37.4 keywords/format/label_allows_punycode().(label: &[u8]) -> bool { |
| 335 |
label.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 |
| 336 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'x' |
| 337 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'n' |
| 338 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 339 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 340 |
} |
| 341 |
|
| 342 |
fn validate_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_label().(label: &[u8]) -> bool { |
| 343 |
if label.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() |
| 344 |
|| label.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().63 |
| 345 |
|| label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 346 |
|| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().label.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 347 |
{ |
| 348 |
return false; |
| 349 |
} |
| 350 |
|
| 351 |
if label.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 && label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' && label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().label_allows_punycoderust-analyzer cargo jsonschema 0.37.4 keywords/format/label_allows_punycode().(label) |
| 352 |
{ |
| 353 |
return false; |
| 354 |
} |
| 355 |
|
| 356 |
true |
| 357 |
} |
| 358 |
|
| 359 |
fn contains_punycode_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/contains_punycode_label().(hostname: &[u8]) -> bool { |
| 360 |
hostname.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split().(|&b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'.').anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|label| { |
| 361 |
label.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 |
| 362 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'x' |
| 363 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'n' |
| 364 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 365 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 366 |
}) |
| 367 |
} |
| 368 |
|
| 369 |
let hostname_bytes = hostname.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 370 |
let len = hostname_bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 371 |
if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 || len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().253 || hostname_bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'.' { |
| 372 |
return false; |
| 373 |
} |
| 374 |
|
| 375 |
let mut label_start = 0; |
| 376 |
let mut i = 0; |
| 377 |
|
| 378 |
while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len { |
| 379 |
if hostname_bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'.' { |
| 380 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_label().(&hostname_bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().label_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 381 |
return false; |
| 382 |
} |
| 383 |
label_start = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 384 |
} else if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().VALID_CHARSrust-analyzer cargo jsonschema 0.37.4 keywords/format/VALID_CHARS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().hostname_bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). { |
| 385 |
return false; |
| 386 |
} |
| 387 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 388 |
} |
| 389 |
|
| 390 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_label().(&hostname_bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().label_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 391 |
return false; |
| 392 |
} |
| 393 |
|
| 394 |
if contains_punycode_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/contains_punycode_label().(hostname_bytes) { |
| 395 |
use idnarust-analyzer cargo idna 1.1.0 crate/::punycoderust-analyzer cargo idna 1.1.0 punycode/; |
| 396 |
for label in hostname_bytes.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split().(|&b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'.') { |
| 397 |
if label.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 |
| 398 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'x' |
| 399 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'n' |
| 400 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 401 |
&& label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'-' |
| 402 |
{ |
| 403 |
let payload = |
| 404 |
stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&label[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("ASCII label already validated"); |
| 405 |
let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(decoded) = punycoderust-analyzer cargo idna 1.1.0 punycode/::decode_to_stringrust-analyzer cargo idna 1.1.0 punycode/decode_to_string().(payload) else { |
| 406 |
return false; |
| 407 |
}; |
| 408 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_unicode_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_unicode_label().(&decoded) { |
| 409 |
return false; |
| 410 |
} |
| 411 |
} |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
true |
| 416 |
} |
| 417 |
|
| 418 |
fn validate_unicode_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_unicode_label().(label: &str) -> bool { |
| 419 |
let mut chars = label.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 420 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&first) = chars.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 421 |
let category = get_general_categoryrust-analyzer cargo unicode-general-category 1.1.0 category/get_general_category().(first); |
| 422 |
if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 423 |
category, |
| 424 |
GeneralCategoryrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#::SpacingMarkrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#SpacingMark# |
| 425 |
| GeneralCategoryrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#::NonspacingMarkrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#NonspacingMark# |
| 426 |
| GeneralCategoryrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#::EnclosingMarkrust-analyzer cargo unicode-general-category 1.1.0 tables/GeneralCategory#EnclosingMark# |
| 427 |
) { |
| 428 |
return false; |
| 429 |
} |
| 430 |
} |
| 431 |
let mut previous = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 432 |
let mut has_katakana_middle_dot = false; |
| 433 |
let mut has_hiragana_katakana_han = false; |
| 434 |
let mut has_arabic_indic_digits = false; |
| 435 |
let mut has_extended_arabic_indic_digits = false; |
| 436 |
|
| 437 |
while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(current) = chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 438 |
match current { |
| 439 |
// ZERO WIDTH JOINER |
| 440 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.2 |
| 441 |
'\u{200D}' |
| 442 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().previous.is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|prev| { |
| 443 |
matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 444 |
prev, |
| 445 |
'\u{094D}' |
| 446 |
| '\u{09CD}' |
| 447 |
| '\u{0A4D}' |
| 448 |
| '\u{0ACD}' |
| 449 |
| '\u{0B4D}' |
| 450 |
| '\u{0BCD}' |
| 451 |
| '\u{0C4D}' |
| 452 |
| '\u{0CCD}' |
| 453 |
| '\u{0D4D}' |
| 454 |
| '\u{0DCA}' |
| 455 |
| '\u{0E3A}' |
| 456 |
| '\u{0F84}' |
| 457 |
| '\u{1039}' |
| 458 |
| '\u{1714}' |
| 459 |
| '\u{1734}' |
| 460 |
| '\u{17D2}' |
| 461 |
| '\u{1A60}' |
| 462 |
| '\u{1B44}' |
| 463 |
| '\u{1BAA}' |
| 464 |
| '\u{1BF2}' |
| 465 |
| '\u{1BF3}' |
| 466 |
| '\u{2D7F}' |
| 467 |
| '\u{A806}' |
| 468 |
| '\u{A8C4}' |
| 469 |
| '\u{A953}' |
| 470 |
| '\u{ABED}' |
| 471 |
| '\u{10A3F}' |
| 472 |
| '\u{11046}' |
| 473 |
| '\u{1107F}' |
| 474 |
| '\u{110B9}' |
| 475 |
| '\u{11133}' |
| 476 |
| '\u{111C0}' |
| 477 |
| '\u{11235}' |
| 478 |
| '\u{112EA}' |
| 479 |
| '\u{1134D}' |
| 480 |
| '\u{11442}' |
| 481 |
| '\u{114C2}' |
| 482 |
| '\u{115BF}' |
| 483 |
| '\u{1163F}' |
| 484 |
| '\u{116B6}' |
| 485 |
| '\u{1172B}' |
| 486 |
| '\u{11839}' |
| 487 |
| '\u{119E0}' |
| 488 |
| '\u{11A34}' |
| 489 |
| '\u{11A47}' |
| 490 |
| '\u{11A99}' |
| 491 |
| '\u{11C3F}' |
| 492 |
| '\u{11D44}' |
| 493 |
| '\u{11D45}' |
| 494 |
| '\u{11D97}' |
| 495 |
) |
| 496 |
}) => |
| 497 |
{ |
| 498 |
return false; |
| 499 |
} |
| 500 |
// MIDDLE DOT |
| 501 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.3 |
| 502 |
'\u{00B7}' if previous rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('l') || chars.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&'l') => return false, |
| 503 |
// Greek KERAIA |
| 504 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.4 |
| 505 |
'\u{0375}' |
| 506 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().chars |
| 507 |
.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() |
| 508 |
.is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|next| ('\u{0370}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{03FF}').containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(next)) => |
| 509 |
{ |
| 510 |
return false |
| 511 |
} |
| 512 |
// Hebrew GERESH and GERSHAYIM |
| 513 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.5 |
| 514 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.6 |
| 515 |
'\u{05F3}' | '\u{05F4}' |
| 516 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().previous.is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|prev| ('\u{0590}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{05FF}').containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(&prev)) => |
| 517 |
{ |
| 518 |
return false |
| 519 |
} |
| 520 |
// KATAKANA MIDDLE DOT |
| 521 |
'\u{30FB}' => has_katakana_middle_dot = true, |
| 522 |
// Hiragana, Katakana, or Han |
| 523 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.7 |
| 524 |
'\u{3040}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{309F}' | '\u{30A0}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{30FF}' | '\u{4E00}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{9FFF}' => { |
| 525 |
has_hiragana_katakana_han = true; |
| 526 |
} |
| 527 |
// ARABIC-INDIC DIGITS |
| 528 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.8 |
| 529 |
'\u{0660}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{0669}' => has_arabic_indic_digits = true, |
| 530 |
// EXTENDED ARABIC-INDIC DIGITS |
| 531 |
// https://www.rfc-editor.org/rfc/rfc5892#appendix-A.9 |
| 532 |
'\u{06F0}'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'\u{06F9}' => has_extended_arabic_indic_digits = true, |
| 533 |
// DISALLOWED |
| 534 |
'\u{0640}' | '\u{07FA}' | '\u{302E}' | '\u{302F}' | '\u{3031}' | '\u{3032}' |
| 535 |
| '\u{3033}' | '\u{3034}' | '\u{3035}' | '\u{303B}' => return false, |
| 536 |
|
| 537 |
_ => {} |
| 538 |
} |
| 539 |
previous = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(current); |
| 540 |
} |
| 541 |
|
| 542 |
if (has_katakana_middle_dot && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_hiragana_katakana_han) |
| 543 |
|| (has_arabic_indic_digits && has_extended_arabic_indic_digits) |
| 544 |
{ |
| 545 |
return false; |
| 546 |
} |
| 547 |
|
| 548 |
true |
| 549 |
} |
| 550 |
|
| 551 |
fn is_valid_idn_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_hostname().(hostname: &str) -> bool { |
| 552 |
use idnarust-analyzer cargo idna 1.1.0 crate/::uts46rust-analyzer cargo idna 1.1.0 uts46/::{AsciiDenyListrust-analyzer cargo idna 1.1.0 uts46/AsciiDenyList#, DnsLengthrust-analyzer cargo idna 1.1.0 uts46/DnsLength#, Hyphensrust-analyzer cargo idna 1.1.0 uts46/Hyphens#, Uts46rust-analyzer cargo idna 1.1.0 uts46/Uts46#}; |
| 553 |
|
| 554 |
let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_hostname) = Uts46rust-analyzer cargo idna 1.1.0 uts46/Uts46#::newrust-analyzer cargo idna 1.1.0 uts46/impl#[Uts46]new().().to_asciirust-analyzer cargo idna 1.1.0 uts46/impl#[Uts46]to_ascii().( |
| 555 |
hostname.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), |
| 556 |
AsciiDenyListrust-analyzer cargo idna 1.1.0 uts46/AsciiDenyList#::STD3rust-analyzer cargo idna 1.1.0 uts46/impl#[AsciiDenyList]STD3., |
| 557 |
// Prohibit hyphens in the first, third, fourth, and last position in the label |
| 558 |
Hyphensrust-analyzer cargo idna 1.1.0 uts46/Hyphens#::Checkrust-analyzer cargo idna 1.1.0 uts46/Hyphens#Check#, |
| 559 |
DnsLengthrust-analyzer cargo idna 1.1.0 uts46/DnsLength#::Verifyrust-analyzer cargo idna 1.1.0 uts46/DnsLength#Verify#, |
| 560 |
) else { |
| 561 |
return false; |
| 562 |
}; |
| 563 |
|
| 564 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().(&ascii_hostname) { |
| 565 |
return false; |
| 566 |
} |
| 567 |
|
| 568 |
let (unicode_hostname, _) = Uts46rust-analyzer cargo idna 1.1.0 uts46/Uts46#::newrust-analyzer cargo idna 1.1.0 uts46/impl#[Uts46]new().().to_unicoderust-analyzer cargo idna 1.1.0 uts46/impl#[Uts46]to_unicode().( |
| 569 |
ascii_hostname.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), |
| 570 |
AsciiDenyListrust-analyzer cargo idna 1.1.0 uts46/AsciiDenyList#::EMPTYrust-analyzer cargo idna 1.1.0 uts46/impl#[AsciiDenyList]EMPTY., |
| 571 |
Hyphensrust-analyzer cargo idna 1.1.0 uts46/Hyphens#::Allowrust-analyzer cargo idna 1.1.0 uts46/Hyphens#Allow#, |
| 572 |
); |
| 573 |
|
| 574 |
unicode_hostname |
| 575 |
.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('.') |
| 576 |
.allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|label| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().label.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() && validate_unicode_labelrust-analyzer cargo jsonschema 0.37.4 keywords/format/validate_unicode_label().(label)) |
| 577 |
} |
| 578 |
|
| 579 |
#[inline] |
| 580 |
fn unit_indexrust-analyzer cargo jsonschema 0.37.4 keywords/format/unit_index().(units: &[u8], unit: u8) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> { |
| 581 |
units.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|&u| u rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().unit) |
| 582 |
} |
| 583 |
|
| 584 |
fn is_valid_durationrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_duration().(duration: &str) -> bool { |
| 585 |
let bytes = duration.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 586 |
let len = bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 587 |
|
| 588 |
if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().2 || bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'P' { |
| 589 |
return false; |
| 590 |
} |
| 591 |
|
| 592 |
let mut i = 1; |
| 593 |
let mut has_component = false; |
| 594 |
let mut has_time = false; |
| 595 |
let mut last_date_unit = 0; |
| 596 |
let mut last_time_unit = 0; |
| 597 |
let mut has_weeks = false; |
| 598 |
let mut has_time_component = false; |
| 599 |
let mut seen_units = 0u8; |
| 600 |
|
| 601 |
let date_units = [b'Y', b'M', b'W', b'D']; |
| 602 |
let time_units = [b'H', b'M', b'S']; |
| 603 |
|
| 604 |
while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len { |
| 605 |
if bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'T' { |
| 606 |
if has_time { |
| 607 |
return false; |
| 608 |
} |
| 609 |
has_time = true; |
| 610 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 611 |
continue; |
| 612 |
} |
| 613 |
|
| 614 |
let start = i; |
| 615 |
while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len && bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_digit().() { |
| 616 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 617 |
} |
| 618 |
|
| 619 |
if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().start || i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().len { |
| 620 |
return false; |
| 621 |
} |
| 622 |
|
| 623 |
let unit = bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 624 |
|
| 625 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_time { |
| 626 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(idx) = unit_indexrust-analyzer cargo jsonschema 0.37.4 keywords/format/unit_index().(&date_units, unit) { |
| 627 |
if unit rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'W' { |
| 628 |
if has_component { |
| 629 |
return false; |
| 630 |
} |
| 631 |
has_weeks = true; |
| 632 |
} else if has_weeks { |
| 633 |
return false; |
| 634 |
} |
| 635 |
if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().last_date_unit || (seen_units rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().idx) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0) { |
| 636 |
return false; |
| 637 |
} |
| 638 |
seen_units rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().idx; |
| 639 |
last_date_unit = idx; |
| 640 |
} else { |
| 641 |
return false; |
| 642 |
} |
| 643 |
} else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(idx) = unit_indexrust-analyzer cargo jsonschema 0.37.4 keywords/format/unit_index().(&time_units, unit) { |
| 644 |
if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().last_time_unit || (seen_units rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0) { |
| 645 |
return false; |
| 646 |
} |
| 647 |
seen_units rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4); |
| 648 |
last_time_unit = idx; |
| 649 |
has_time_component = true; |
| 650 |
} else { |
| 651 |
return false; |
| 652 |
} |
| 653 |
|
| 654 |
has_component = true; |
| 655 |
i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 656 |
} |
| 657 |
|
| 658 |
has_component && (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_time || has_time_component) |
| 659 |
} |
| 660 |
|
| 661 |
fn is_valid_ipv4rust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_ipv4().(ip: &str) -> bool { |
| 662 |
Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::from_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/parser/impl#[Ipv4Addr][FromStr]from_str().(ip).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 663 |
} |
| 664 |
|
| 665 |
fn is_valid_ipv6rust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_ipv6().(ip: &str) -> bool { |
| 666 |
Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#::from_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/parser/impl#[Ipv6Addr][FromStr]from_str().(ip).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 667 |
} |
| 668 |
|
| 669 |
fn is_valid_irirust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_iri().(iri: &str) -> bool { |
| 670 |
referencingrust-analyzer cargo referencing 0.37.4 crate/::Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`]parse().(iri).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 671 |
} |
| 672 |
|
| 673 |
fn is_valid_iri_referencerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_iri_reference().(iri_reference: &str) -> bool { |
| 674 |
referencingrust-analyzer cargo referencing 0.37.4 crate/::IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`IriRef<T>`]parse().(iri_reference).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 675 |
} |
| 676 |
|
| 677 |
fn is_valid_urirust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri().(uri: &str) -> bool { |
| 678 |
referencingrust-analyzer cargo referencing 0.37.4 crate/::Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().(uri).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 679 |
} |
| 680 |
|
| 681 |
fn is_valid_uri_referencerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri_reference().(uri_reference: &str) -> bool { |
| 682 |
referencingrust-analyzer cargo referencing 0.37.4 crate/::UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`UriRef<T>`]parse().(uri_reference).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 683 |
} |
| 684 |
|
| 685 |
fn is_valid_regexrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_regex().(regex: &str) -> bool { |
| 686 |
ecmarust-analyzer cargo jsonschema 0.37.4 ecma/::to_rust_regexrust-analyzer cargo jsonschema 0.37.4 ecma/to_rust_regex().(regex).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 687 |
} |
| 688 |
|
| 689 |
fn is_valid_uri_templaterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri_template().(uri_template: &str) -> bool { |
| 690 |
URI_TEMPLATE_RErust-analyzer cargo jsonschema 0.37.4 keywords/format/URI_TEMPLATE_RE. |
| 691 |
.is_matchrust-analyzer cargo fancy-regex 0.11.0 impl#[Regex]is_match().(uri_template) |
| 692 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Simple URI_TEMPLATE_RE pattern") |
| 693 |
} |
| 694 |
|
| 695 |
fn is_valid_uuidrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uuid().(uuid: &str) -> bool { |
| 696 |
let mut out = [0; 16]; |
| 697 |
parse_hyphenatedrust-analyzer cargo uuid-simd 0.8.0 parse_hyphenated().(uuid.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), Outrust-analyzer cargo outref 0.5.2 Out#::from_mutrust-analyzer cargo outref 0.5.2 impl#[`Out<'a, T>`]from_mut().(&mut out)).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 698 |
} |
| 699 |
|
| 700 |
macro_rules! format_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/format/format_validators! { |
| 701 |
($(($validator:ident, $format:expr, $validation_fn:ident)),+ $(,)?) => { |
| 702 |
$( |
| 703 |
struct $validator { |
| 704 |
location: Location, |
| 705 |
} |
| 706 |
|
| 707 |
impl $validator { |
| 708 |
pub(crate) fn compile<'a>(ctx: &compiler::Context) -> CompilationResult<'a> { |
| 709 |
let location = ctx.location().join("format"); |
| 710 |
Ok(Box::new($validator { location })) |
| 711 |
} |
| 712 |
} |
| 713 |
|
| 714 |
impl Validate for $validator { |
| 715 |
fn is_valid(&self, instance: &Value, _ctx: &mut ValidationContext) -> bool { |
| 716 |
if let Value::String(item) = instance { |
| 717 |
$validation_fn(item) |
| 718 |
} else { |
| 719 |
true |
| 720 |
} |
| 721 |
} |
| 722 |
|
| 723 |
fn validate<'i>( |
| 724 |
&self, |
| 725 |
instance: &'i Value, |
| 726 |
location: &LazyLocation, |
| 727 |
ctx: &mut ValidationContext, |
| 728 |
) -> Result<(), ValidationError<'i>> { |
| 729 |
if let Value::String(_item) = instance { |
| 730 |
if !self.is_valid(instance, ctx) { |
| 731 |
return Err(ValidationError::format( |
| 732 |
self.location.clone(), |
| 733 |
location.into(), |
| 734 |
instance, |
| 735 |
$format, |
| 736 |
)); |
| 737 |
} |
| 738 |
} |
| 739 |
Ok(()) |
| 740 |
} |
| 741 |
} |
| 742 |
)+ |
| 743 |
}; |
| 744 |
} |
| 745 |
format_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/format/format_validators!!( |
| 746 |
(DateValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DateValidator#, "date", is_valid_daterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_date().), |
| 747 |
(DateTimeValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DateTimeValidator#, "date-time", is_valid_datetimerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_datetime().), |
| 748 |
(DurationValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DurationValidator#, "duration", is_valid_durationrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_duration().), |
| 749 |
(EmailValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/EmailValidator#, "email", is_valid_emailrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_email().), |
| 750 |
(HostnameValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/HostnameValidator#, "hostname", is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().), |
| 751 |
(IdnEmailValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IdnEmailValidator#, "idn-email", is_valid_idn_emailrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_email().), |
| 752 |
(IdnHostnameValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IdnHostnameValidator#, "idn-hostname", is_valid_idn_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_hostname().), |
| 753 |
(IpV4Validatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IpV4Validator#, "ipv4", is_valid_ipv4rust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_ipv4().), |
| 754 |
(IpV6Validatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IpV6Validator#, "ipv6", is_valid_ipv6rust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_ipv6().), |
| 755 |
(IriValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IriValidator#, "iri", is_valid_irirust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_iri().), |
| 756 |
( |
| 757 |
IriReferenceValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IriReferenceValidator#, |
| 758 |
"iri-reference", |
| 759 |
is_valid_iri_referencerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_iri_reference(). |
| 760 |
), |
| 761 |
(JsonPointerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/JsonPointerValidator#, "json-pointer", is_valid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer().), |
| 762 |
(RegexValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/RegexValidator#, "regex", is_valid_regexrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_regex().), |
| 763 |
( |
| 764 |
RelativeJsonPointerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/RelativeJsonPointerValidator#, |
| 765 |
"relative-json-pointer", |
| 766 |
is_valid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_relative_json_pointer(). |
| 767 |
), |
| 768 |
(TimeValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/TimeValidator#, "time", is_valid_timerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_time().), |
| 769 |
(UriValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriValidator#, "uri", is_valid_urirust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri().), |
| 770 |
( |
| 771 |
UriReferenceValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriReferenceValidator#, |
| 772 |
"uri-reference", |
| 773 |
is_valid_uri_referencerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri_reference(). |
| 774 |
), |
| 775 |
(UriTemplateValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriTemplateValidator#, "uri-template", is_valid_uri_templaterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uri_template().), |
| 776 |
(UuidValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UuidValidator#, "uuid", is_valid_uuidrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_uuid().), |
| 777 |
); |
| 778 |
|
| 779 |
struct CustomFormatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator# { |
| 780 |
locationrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 781 |
format_namerust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#format_name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 782 |
checkrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#check.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<dyn Formatrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format#>, |
| 783 |
} |
| 784 |
impl CustomFormatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator# { |
| 785 |
pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[CustomFormatValidator]compile().<'a>( |
| 786 |
ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 787 |
format_name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 788 |
check: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<dyn Formatrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format#>, |
| 789 |
) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 790 |
let location = ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("format"); |
| 791 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(CustomFormatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator# { |
| 792 |
locationrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#location., |
| 793 |
format_namerust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#format_name., |
| 794 |
checkrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#check., |
| 795 |
})) |
| 796 |
} |
| 797 |
} |
| 798 |
|
| 799 |
impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for CustomFormatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator# { |
| 800 |
fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[CustomFormatValidator][Validate]validate().<'i>( |
| 801 |
&self, |
| 802 |
instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 803 |
location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 804 |
ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 805 |
) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 806 |
if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[CustomFormatValidator][Validate]is_valid().(instance, ctx) { |
| 807 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 808 |
} else { |
| 809 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::formatrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]format().( |
| 810 |
self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 811 |
location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 812 |
instance, |
| 813 |
self.format_namerust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#format_name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), |
| 814 |
)) |
| 815 |
} |
| 816 |
} |
| 817 |
|
| 818 |
fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[CustomFormatValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 819 |
if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(item) = instance { |
| 820 |
self.checkrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#check..is_validrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format#is_valid().(item) |
| 821 |
} else { |
| 822 |
true |
| 823 |
} |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) trait Formatrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format#: ThreadBoundrust-analyzer cargo jsonschema 0.37.4 thread/ThreadBound# + 'static { |
| 828 |
fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format#is_valid().(&self, value: &str) -> bool; |
| 829 |
} |
| 830 |
|
| 831 |
impl<F> Formatrust-analyzer cargo jsonschema 0.37.4 keywords/format/Format# for F |
| 832 |
where |
| 833 |
F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&str) -> bool + ThreadBoundrust-analyzer cargo jsonschema 0.37.4 thread/ThreadBound# + 'static, |
| 834 |
{ |
| 835 |
#[inline] |
| 836 |
fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[F][Format]is_valid().(&self, value: &str) -> bool { |
| 837 |
self(value) |
| 838 |
} |
| 839 |
} |
| 840 |
|
| 841 |
#[inline] |
| 842 |
pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/compile().<'a>( |
| 843 |
ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 844 |
_: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, |
| 845 |
schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 846 |
) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 847 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ctx.validates_formats_by_defaultrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]validates_formats_by_default().() { |
| 848 |
return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 849 |
} |
| 850 |
|
| 851 |
if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(format) = schema { |
| 852 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((name, func)) = ctx.get_formatrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]get_format().(format) { |
| 853 |
return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CustomFormatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/CustomFormatValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[CustomFormatValidator]compile().( |
| 854 |
ctx, |
| 855 |
name.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), |
| 856 |
func.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 857 |
)); |
| 858 |
} |
| 859 |
let draft = ctx.draftrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]draft().(); |
| 860 |
match format.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 861 |
"date" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DateValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DateValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[DateValidator]compile().(ctx)), |
| 862 |
"date-time" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DateTimeValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DateTimeValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[DateTimeValidator]compile().(ctx)), |
| 863 |
"duration" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DurationValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/DurationValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[DurationValidator]compile().(ctx)), |
| 864 |
"email" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(EmailValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/EmailValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[EmailValidator]compile().(ctx)), |
| 865 |
"hostname" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HostnameValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/HostnameValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[HostnameValidator]compile().(ctx)), |
| 866 |
"idn-email" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IdnEmailValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IdnEmailValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IdnEmailValidator]compile().(ctx)), |
| 867 |
"idn-hostname" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IdnHostnameValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IdnHostnameValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IdnHostnameValidator]compile().(ctx)), |
| 868 |
"ipv4" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IpV4Validatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IpV4Validator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IpV4Validator]compile().(ctx)), |
| 869 |
"ipv6" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IpV6Validatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IpV6Validator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IpV6Validator]compile().(ctx)), |
| 870 |
"iri" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IriValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IriValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IriValidator]compile().(ctx)), |
| 871 |
"iri-reference" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IriReferenceValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/IriReferenceValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[IriReferenceValidator]compile().(ctx)), |
| 872 |
"json-pointer" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(JsonPointerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/JsonPointerValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[JsonPointerValidator]compile().(ctx)), |
| 873 |
"regex" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RegexValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/RegexValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[RegexValidator]compile().(ctx)), |
| 874 |
"relative-json-pointer" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => { |
| 875 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RelativeJsonPointerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/RelativeJsonPointerValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[RelativeJsonPointerValidator]compile().(ctx)) |
| 876 |
} |
| 877 |
"time" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TimeValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/TimeValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[TimeValidator]compile().(ctx)), |
| 878 |
"uri" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UriValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[UriValidator]compile().(ctx)), |
| 879 |
"uri-reference" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UriReferenceValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriReferenceValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[UriReferenceValidator]compile().(ctx)), |
| 880 |
"uri-template" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UriTemplateValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UriTemplateValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[UriTemplateValidator]compile().(ctx)), |
| 881 |
"uuid" if draft rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UuidValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/format/UuidValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/format/impl#[UuidValidator]compile().(ctx)), |
| 882 |
name => { |
| 883 |
if ctx.are_unknown_formats_ignoredrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]are_unknown_formats_ignored().() { |
| 884 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 885 |
} else { |
| 886 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::customrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]custom().( |
| 887 |
Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("format"), |
| 888 |
ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 889 |
schema, |
| 890 |
formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Unknown format: '{name}'. Adjust configuration to ignore unrecognized formats"), |
| 891 |
))) |
| 892 |
} |
| 893 |
} |
| 894 |
} |
| 895 |
} else { |
| 896 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().( |
| 897 |
Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 898 |
ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 899 |
schema, |
| 900 |
JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Stringrust-analyzer cargo jsonschema 0.37.4 types/JsonType#String#, |
| 901 |
))) |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
#[cfg(test)] |
| 906 |
mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/ { |
| 907 |
use referencingrust-analyzer cargo referencing 0.37.4 crate/::Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#; |
| 908 |
use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!; |
| 909 |
use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 910 |
|
| 911 |
use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 912 |
|
| 913 |
use superrust-analyzer cargo jsonschema 0.37.4 keywords/format/::*; |
| 914 |
|
| •915 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"00" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0); "min")] |
| 916 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"09" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(9); "nine")] |
| 917 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"10" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(10); "ten")] |
| 918 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"59" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(59); "fifty-nine")] |
| 919 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"99" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(99); "max")] |
| 920 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"1a" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "alpha")] |
| 921 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b" 5" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "leading space")] |
| 922 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b":0" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "colon is not a digit")] |
| 923 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b";9" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "semicolon is not a digit")] |
| 924 |
fn test_parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_parse_two_digits().(bytes: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 925 |
parse_two_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_two_digits().(bytes) |
| 926 |
} |
| 927 |
|
| 928 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"0000" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0); "zero")] |
| 929 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"1970" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1970); "epoch year")] |
| 930 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"2023" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2023); "recent year")] |
| 931 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"9999" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(9999); "max")] |
| 932 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"199x" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "trailing alpha")] |
| 933 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b" 999" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "leading space")] |
| 934 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(b"20:3" => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; "colon is not a digit")] |
| 935 |
fn test_parse_four_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_parse_four_digits().(bytes: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u16> { |
| 936 |
parse_four_digitsrust-analyzer cargo jsonschema 0.37.4 keywords/format/parse_four_digits().(bytes) |
| 937 |
} |
| 938 |
|
| 939 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 940 |
fn ignored_formatrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/ignored_format().() { |
| 941 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "custom", "type": "string"}); |
| 942 |
let instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("foo"); |
| 943 |
let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 944 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&instance)); |
| 945 |
} |
| 946 |
|
| 947 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 948 |
fn format_validationrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/format_validation().() { |
| 949 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "email", "type": "string"}); |
| 950 |
let email_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("[email protected]"); |
| 951 |
let not_email_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("foo"); |
| 952 |
|
| 953 |
let with_validation = craterust-analyzer cargo jsonschema 0.37.4 crate/::optionsrust-analyzer cargo jsonschema 0.37.4 options().() |
| 954 |
.should_validate_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_validate_formats().(true) |
| 955 |
.buildrust-analyzer cargo jsonschema 0.37.4 options/impl#[ValidationOptions]build().(&schema) |
| 956 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 957 |
let without_validation = craterust-analyzer cargo jsonschema 0.37.4 crate/::optionsrust-analyzer cargo jsonschema 0.37.4 options().() |
| 958 |
.should_validate_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_validate_formats().(false) |
| 959 |
.buildrust-analyzer cargo jsonschema 0.37.4 options/impl#[ValidationOptions]build().(&schema) |
| 960 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 961 |
|
| 962 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(with_validation.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&email_instance)); |
| 963 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().with_validation.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(¬_email_instance)); |
| 964 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(without_validation.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&email_instance)); |
| 965 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(without_validation.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(¬_email_instance)); |
| 966 |
} |
| 967 |
|
| 968 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 969 |
fn ecma_regexrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/ecma_regex().() { |
| 970 |
// See GH-230 |
| 971 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "regex", "type": "string"}); |
| 972 |
let instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("^\\cc$"); |
| 973 |
let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 974 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&instance)); |
| 975 |
} |
| 976 |
|
| 977 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 978 |
fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/location().() { |
| 979 |
tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "date"}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("bla"), "/format"); |
| 980 |
} |
| 981 |
|
| 982 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 983 |
fn uuidrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/uuid().() { |
| 984 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "uuid", "type": "string"}); |
| 985 |
|
| 986 |
let passing_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("f308a72c-fa84-11eb-9a03-0242ac130003"); |
| 987 |
let failing_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("1"); |
| 988 |
|
| 989 |
let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::optionsrust-analyzer cargo jsonschema 0.37.4 options().() |
| 990 |
.with_draftrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]with_draft().(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#) |
| 991 |
.should_validate_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_validate_formats().(true) |
| 992 |
.buildrust-analyzer cargo jsonschema 0.37.4 options/impl#[ValidationOptions]build().(&schema) |
| 993 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 994 |
|
| 995 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&passing_instance)); |
| 996 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&failing_instance)); |
| 997 |
} |
| 998 |
|
| 999 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1000 |
fn urirust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/uri().() { |
| 1001 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "uri", "type": "string"}); |
| 1002 |
|
| 1003 |
let passing_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("https://phillip.com"); |
| 1004 |
let failing_instance = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("redis"); |
| 1005 |
|
| 1006 |
tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &passing_instance); |
| 1007 |
tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &failing_instance); |
| 1008 |
} |
| 1009 |
|
| 1010 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("P1Y1Y")] |
| 1011 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("PT1H1H")] |
| 1012 |
fn test_invalid_durationrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_duration().(input: &str) { |
| 1013 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_durationrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_duration().(input)); |
| 1014 |
} |
| 1015 |
|
| 1016 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1017 |
fn unknown_formats_should_not_be_ignoredrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/unknown_formats_should_not_be_ignored().() { |
| 1018 |
let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ "format": "custom", "type": "string"}); |
| 1019 |
let error = craterust-analyzer cargo jsonschema 0.37.4 crate/::optionsrust-analyzer cargo jsonschema 0.37.4 options().() |
| 1020 |
.should_validate_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_validate_formats().(true) |
| 1021 |
.should_ignore_unknown_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_ignore_unknown_formats().(false) |
| 1022 |
.buildrust-analyzer cargo jsonschema 0.37.4 options/impl#[ValidationOptions]build().(&schema) |
| 1023 |
.expect_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect_err().("the validation error should be returned"); |
| 1024 |
|
| 1025 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1026 |
error.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1027 |
"Unknown format: 'custom'. Adjust configuration to ignore unrecognized formats" |
| 1028 |
); |
| 1029 |
} |
| 1030 |
|
| 1031 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-01-01", true; "valid regular date")] |
| 1032 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2020-02-29", true; "valid leap year date")] |
| 1033 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2021-02-28", true; "valid non-leap year date")] |
| 1034 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1900-02-28", true; "valid century non-leap year")] |
| 1035 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2000-02-29", true; "valid leap century year")] |
| 1036 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1999-12-31", true; "valid end of year date")] |
| 1037 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("202-12-01", false; "invalid short year")] |
| 1038 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-1-01", false; "invalid short month")] |
| 1039 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-12-1", false; "invalid short day")] |
| 1040 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023/12/01", false; "invalid separators")] |
| 1041 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-13-01", false; "invalid month too high")] |
| 1042 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-00-01", false; "invalid month too low")] |
| 1043 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-12-32", false; "invalid day too high")] |
| 1044 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-11-31", false; "invalid day for 30-day month")] |
| 1045 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-02-30", false; "invalid day for February in non-leap year")] |
| 1046 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2021-02-29", false; "invalid day for non-leap year")] |
| 1047 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2023-12-00", false; "invalid day too low")] |
| 1048 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("99999-12-01", false; "year too long")] |
| 1049 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1900-02-29", false; "invalid leap century non-leap year")] |
| 1050 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2000-02-30", false; "invalid day for leap century year")] |
| 1051 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2400-02-29", true; "valid leap year in distant future")] |
| 1052 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("0000-01-01", true; "valid boundary start date")] |
| 1053 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("9999-12-31", true; "valid boundary end date")] |
| 1054 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("aaaa-01-12", false; "Malformed (letters in year)")] |
| 1055 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2000-bb-12", false; "Malformed (letters in month)")] |
| 1056 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2000-01-cc", false; "Malformed (letters in day)")] |
| •1057 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("20:3-01-15", false; "colon in year")] |
| 1058 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("20;3-01-15", false; "semicolon in year")] |
| 1059 |
fn test_is_valid_daterust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_is_valid_date().(input: &str, expected: bool) { |
| 1060 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_daterust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_date().(input), expected); |
| 1061 |
} |
| 1062 |
|
| 1063 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:59Z", true; "valid time with Z")] |
| 1064 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("00:00:00Z", true; "valid midnight time with Z")] |
| 1065 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45.123Z", true; "valid time with fractional seconds and Z")] |
| 1066 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60Z", true; "valid leap second UTC time")] |
| 1067 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45+01:00", true; "valid time with positive offset")] |
| 1068 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45-01:00", true; "valid time with negative offset")] |
| 1069 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60+00:00", true; "valid leap second with offset UTC 00:00")] |
| 1070 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:59+01:00", true; "valid time with +01:00 offset")] |
| 1071 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:59A", false; "invalid time with non-Z/non-offset letter")] |
| 1072 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:3:45Z", false; "invalid time with missing digit in minute")] |
| 1073 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:4Z", false; "invalid time with missing digit in second")] |
| 1074 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12-30-45Z", false; "invalid time with wrong separator")] |
| 1075 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45Z+01:00", false; "invalid time with Z and offset together")] |
| 1076 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45A01:00", false; "invalid time with wrong separator between time and offset")] |
| 1077 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45++01:00", false; "invalid double plus in offset")] |
| 1078 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45+01:60", false; "invalid minute in offset")] |
| 1079 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45+24:00", false; "invalid hour in offset")] |
| 1080 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45.", false; "invalid time with incomplete fractional second")] |
| 1081 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("24:00:00Z", false; "invalid hour > 23")] |
| 1082 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:60:00Z", false; "invalid minute > 59")] |
| 1083 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:61Z", false; "invalid second > 60")] |
| 1084 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:60+01:00", false; "invalid leap second with non-UTC offset")] |
| 1085 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60Z+01:00", false; "invalid leap second with non-zero offset")] |
| 1086 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60+00:30", false; "invalid leap second with non-zero minute offset")] |
| 1087 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60Z", true; "valid leap second at the end of day")] |
| 1088 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:60+00:00", true; "valid leap second with zero offset")] |
| 1089 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("ab:59:59Z", false; "invalid time with letters in hour")] |
| 1090 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:ab:59Z", false; "invalid time with letters in minute")] |
| 1091 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:abZ", false; "invalid time with letters in second")] |
| 1092 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("23:59:59aZ", false; "invalid time with letter after seconds")] |
| 1093 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45+ab:00", false; "invalid offset hour with letters")] |
| 1094 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45+01:ab", false; "invalid offset minute with letters")] |
| 1095 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("12:30:45.abcZ", false; "invalid fractional seconds with letters")] |
| 1096 |
fn test_is_valid_timerust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_is_valid_time().(input: &str, expected: bool) { |
| 1097 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_timerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_time().(input), expected); |
| 1098 |
} |
| 1099 |
|
| 1100 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1101 |
fn test_is_valid_datetimerust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_is_valid_datetime().() { |
| 1102 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_datetimerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_datetime().("")); |
| 1103 |
} |
| 1104 |
|
| 1105 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("127.0.0.1", true)] |
| 1106 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("192.168.1.1", true)] |
| 1107 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("10.0.0.1", true)] |
| 1108 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("0.0.0.0", true)] |
| 1109 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("256.1.2.3", false; "first octet too large")] |
| 1110 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.256.3.4", false; "second octet too large")] |
| 1111 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.256.4", false; "third octet too large")] |
| 1112 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.3.256", false; "fourth octet too large")] |
| 1113 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("01.2.3.4", false; "leading zero in first octet")] |
| 1114 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.02.3.4", false; "leading zero in second octet")] |
| 1115 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.03.4", false; "leading zero in third octet")] |
| 1116 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.3.04", false; "leading zero in fourth octet")] |
| 1117 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.3", false; "too few octets")] |
| 1118 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.2.3.4.5", false; "too many octets")] |
| 1119 |
fn ip_v4rust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/ip_v4().(input: &str, expected: bool) { |
| 1120 |
let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::optionsrust-analyzer cargo jsonschema 0.37.4 options().() |
| 1121 |
.should_validate_formatsrust-analyzer cargo jsonschema 0.37.4 options/impl#[`ValidationOptions<R>`]should_validate_formats().(true) |
| 1122 |
.buildrust-analyzer cargo jsonschema 0.37.4 options/impl#[ValidationOptions]build().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "ipv4", "type": "string"})) |
| 1123 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid schema"); |
| 1124 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(input)), expected); |
| 1125 |
} |
| 1126 |
|
| 1127 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1128 |
fn test_is_valid_datetime_panicrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_is_valid_datetime_panic().() { |
| 1129 |
is_valid_datetimerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_datetime().("2624-04-25t23:14:04-256\x112"); |
| 1130 |
} |
| 1131 |
|
| 1132 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("example.com" ; "simple valid hostname")] |
| 1133 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--bcher-kva.com" ; "valid punycode")] |
| 1134 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("münchen.de" ; "valid IDN")] |
| 1135 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("test\u{094D}\u{200D}example.com" ; "valid zero width joiner after virama")] |
| 1136 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("۱۲۳.example.com" ; "valid extended arabic-indic digits")] |
| 1137 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("ひらがな・カタカナ.com" ; "valid katakana middle dot")] |
| 1138 |
fn test_valid_idn_hostnamesrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_valid_idn_hostnames().(input: &str) { |
| 1139 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_valid_idn_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_hostname().(input)); |
| 1140 |
} |
| 1141 |
|
| 1142 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--ll-0ea" ; "punycode with valid middle dot context")] |
| 1143 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--11b2ezcw70k" ; "zero width joiner preceded by virama")] |
| 1144 |
fn test_valid_punycode_hostnamesrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_valid_punycode_hostnames().(input: &str) { |
| 1145 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().(input)); |
| 1146 |
} |
| 1147 |
|
| 1148 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("ex--ample.com" ; "hyphen at 3rd & 4th position")] |
| 1149 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("-example.com" ; "leading hyphen")] |
| 1150 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("example-.com" ; "trailing hyphen")] |
| 1151 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--example.com" ; "invalid punycode")] |
| 1152 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--x" ; "too short punycode label")] |
| 1153 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--vek" ; "katakana middle dot without companions")] |
| 1154 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--l-fda" ; "middle dot with nothing preceding")] |
| 1155 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--l-gda" ; "middle dot with nothing following")] |
| 1156 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--02b508i" ; "zero width joiner not preceded by virama")] |
| 1157 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--a-2hc5h" ; "hebrew geresh not preceded by hebrew")] |
| 1158 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--a-2hc8h" ; "hebrew gershayim not preceded by hebrew")] |
| 1159 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("test\u{200D}example.com" ; "zero width joiner not after virama")] |
| 1160 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("test\u{0061}\u{200D}example.com" ; "zero width joiner after non-virama")] |
| 1161 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("" ; "empty string")] |
| 1162 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("." ; "single dot")] |
| 1163 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("example..com" ; "consecutive dots")] |
| 1164 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("exa mple.com" ; "contains space")] |
| 1165 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("example.com." ; "trailing dot")] |
| 1166 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com" ; "too long")] |
| 1167 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--bcher-.com" ; "invalid punycode with hyphen")] |
| 1168 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("١۲٣.example.com" ; "mixed arabic-indic digits")] |
| 1169 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("example・com" ; "katakana middle dot without hiragana/katakana/han")] |
| 1170 |
fn test_invalid_idn_hostnamesrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_idn_hostnames().(input: &str) { |
| 1171 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_idn_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_idn_hostname().(input)); |
| 1172 |
} |
| 1173 |
|
| 1174 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--l-fda" ; "middle dot with nothing preceding")] |
| 1175 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--l-gda" ; "middle dot with nothing following")] |
| 1176 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--02b508i" ; "zero width joiner not preceded by anything")] |
| 1177 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--11b2er09f" ; "zero width joiner not preceded by virama")] |
| 1178 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--hello-zed" ; "punycode beginning with nonspacing mark")] |
| 1179 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--hello-txk" ; "punycode beginning with spacing combining mark")] |
| 1180 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("xn--hello-6bf" ; "punycode beginning with enclosing mark")] |
| 1181 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("XN--aa---o47jg78q" ; "uppercase punycode prefix rejected")] |
| 1182 |
fn test_invalid_punycode_hostnamesrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_punycode_hostnames().(input: &str) { |
| 1183 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().(input)); |
| 1184 |
} |
| 1185 |
|
| 1186 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1187 |
fn test_invalid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_hostname().() { |
| 1188 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_hostnamerust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_hostname().("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com")); |
| 1189 |
} |
| 1190 |
|
| 1191 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(""; "empty string")] |
| 1192 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/"; "root")] |
| 1193 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo"; "simple key")] |
| 1194 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo/0"; "array index")] |
| 1195 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo/bar"; "nested keys")] |
| 1196 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/f~0o/b~1r"; "escaped characters")] |
| 1197 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo/bar/"; "trailing slash")] |
| 1198 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo//bar"; "empty reference token")] |
| 1199 |
fn test_valid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_valid_json_pointer().(pointer: &str) { |
| 1200 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_valid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer().(pointer)); |
| 1201 |
} |
| 1202 |
|
| 1203 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("foo"; "missing leading slash")] |
| 1204 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo/~"; "incomplete escape")] |
| 1205 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo/~2"; "invalid escape")] |
| 1206 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("/foo\x7E"; "unescaped tilde")] |
| 1207 |
fn test_invalid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_json_pointer().(pointer: &str) { |
| 1208 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_json_pointer().(pointer)); |
| 1209 |
} |
| 1210 |
|
| 1211 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("0"; "zero")] |
| 1212 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1"; "positive integer")] |
| 1213 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("10"; "multi-digit integer")] |
| 1214 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("0#"; "zero with hash")] |
| 1215 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1#"; "positive integer with hash")] |
| 1216 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("0/"; "zero with slash")] |
| 1217 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1/foo"; "integer with json pointer")] |
| 1218 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("10/foo/bar"; "multi-digit integer with json pointer")] |
| 1219 |
fn test_valid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_valid_relative_json_pointer().(pointer: &str) { |
| 1220 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_valid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_relative_json_pointer().(pointer)); |
| 1221 |
} |
| 1222 |
|
| 1223 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(""; "empty string")] |
| 1224 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("-1"; "negative integer")] |
| 1225 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("01"; "leading zero")] |
| 1226 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1.5"; "decimal")] |
| 1227 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("a"; "non-digit")] |
| 1228 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1a"; "digit followed by non-digit")] |
| 1229 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1#/"; "hash not at end")] |
| 1230 |
#[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1/~"; "incomplete escape in json pointer")] |
| 1231 |
fn test_invalid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/tests/test_invalid_relative_json_pointer().(pointer: &str) { |
| 1232 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_relative_json_pointerrust-analyzer cargo jsonschema 0.37.4 keywords/format/is_valid_relative_json_pointer().(pointer)); |
| 1233 |
} |
| 1234 |
} |