| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 2 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/, |
| 3 | errorrust-analyzer cargo jsonschema 0.37.4 error/::ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, |
| 4 | extrust-analyzer cargo jsonschema 0.37.4 ext/::numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/, |
| 5 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 6 | 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#}, |
| 7 | threadrust-analyzer cargo jsonschema 0.37.4 thread/::ThreadBoundrust-analyzer cargo jsonschema 0.37.4 thread/ThreadBound#, |
| 8 | typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#, |
| 9 | 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#}, |
| 10 | }; |
| 11 | use num_cmprust-analyzer cargo num-cmp 0.1.0 crate/::NumCmprust-analyzer cargo num-cmp 0.1.0 NumCmp#; |
| 12 | 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#}; |
| 13 | |
| 14 | macro_rules! define_numeric_keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/define_numeric_keywords! { |
| 15 | ($($struct_name:ident => $fn_name:path => $error_fn_name:ident),* $(,)?) => { |
| 16 | $( |
| 17 | #[derive(Debug, Clone, PartialEq)] |
| 18 | pub(crate) struct $struct_name<T> { |
| 19 | pub(super) limit: T, |
| 20 | limit_val: Value, |
| 21 | location: Location, |
| 22 | } |
| 23 | |
| 24 | impl<T> From<(T, Value, Location)> for $struct_name<T> { |
| 25 | fn from((limit, limit_val, location): (T, Value, Location)) -> Self { |
| 26 | Self { limit, limit_val, location } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | impl<T> Validate for $struct_name<T> |
| 31 | where |
| 32 | T: Copy + ThreadBound + num_traits::ToPrimitive, |
| 33 | u64: NumCmp<T>, |
| 34 | i64: NumCmp<T>, |
| 35 | f64: NumCmp<T>, |
| 36 | { |
| 37 | fn validate<'i>( |
| 38 | &self, |
| 39 | instance: &'i Value, |
| 40 | location: &LazyLocation, |
| 41 | ctx: &mut ValidationContext, |
| 42 | ) -> Result<(), ValidationError<'i>> { |
| 43 | if self.is_valid(instance, ctx) { |
| 44 | Ok(()) |
| 45 | } else { |
| 46 | Err(ValidationError::$error_fn_name( |
| 47 | self.location.clone(), |
| 48 | location.into(), |
| 49 | instance, |
| 50 | self.limit_val.clone(), |
| 51 | )) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | fn is_valid(&self, instance: &Value, _ctx: &mut ValidationContext) -> bool { |
| 56 | if let Value::Number(item) = instance { |
| 57 | $fn_name(item, self.limit) |
| 58 | } else { |
| 59 | true |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | )* |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | define_numeric_keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/define_numeric_keywords!!( |
| 68 | Minimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/Minimum# => numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::gerust-analyzer cargo jsonschema 0.37.4 ext/numeric/ge(). => minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]minimum()., |
| 69 | Maximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/Maximum# => numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::lerust-analyzer cargo jsonschema 0.37.4 ext/numeric/le(). => maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]maximum()., |
| 70 | ExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/ExclusiveMinimum# => numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::gtrust-analyzer cargo jsonschema 0.37.4 ext/numeric/gt(). => exclusive_minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_minimum()., |
| 71 | ExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/ExclusiveMaximum# => numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::ltrust-analyzer cargo jsonschema 0.37.4 ext/numeric/lt(). => exclusive_maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_maximum()., |
| 72 | ); |
| 73 | |
| 74 | #[cfg(feature = "arbitrary-precision")] |
| 75 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) mod bigint_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/ { |
| 76 | use superrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/::{ |
| 77 | numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/, LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 78 | }; |
| 79 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::extrust-analyzer cargo jsonschema 0.37.4 ext/::numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::{ |
| 80 | f64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_ge_bigfrac()., f64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_ge_bigint()., f64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_gt_bigfrac()., f64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_gt_bigint()., f64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_le_bigfrac()., |
| 81 | f64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_le_bigint()., f64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_lt_bigfrac()., f64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_lt_bigint()., i64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_ge_bigfrac()., i64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_ge_bigint()., |
| 82 | i64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_gt_bigfrac()., i64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_gt_bigint()., i64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_le_bigfrac()., i64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_le_bigint()., i64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_lt_bigfrac()., |
| 83 | i64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_lt_bigint()., try_parse_bigfractionrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigfraction()., u64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_ge_bigfrac()., u64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_ge_bigint()., u64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_gt_bigfrac()., |
| 84 | u64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_gt_bigint()., u64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_le_bigfrac()., u64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_le_bigint()., u64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_lt_bigfrac()., u64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_lt_bigint()., |
| 85 | }; |
| 86 | use num_bigintrust-analyzer cargo num-bigint 0.4.6 crate/::BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#; |
| 87 | |
| 88 | macro_rules! define_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigint_validator! { |
| 89 | ($struct_name:ident, $u64_cmp:path, $i64_cmp:path, $f64_cmp:path, $bigint_op:tt, $error_fn:ident, $infinity_fn:expr) => { |
| 90 | #[derive(Debug, Clone, PartialEq)] |
| 91 | pub(crate) struct $struct_name { |
| 92 | pub(super) limit: BigInt, |
| 93 | pub(super) limit_val: Value, |
| 94 | pub(super) location: Location, |
| 95 | } |
| 96 | |
| 97 | impl $struct_name { |
| 98 | pub(crate) fn new(limit: BigInt, limit_val: Value, location: Location) -> Self { |
| 99 | Self { limit, limit_val, location } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | impl Validate for $struct_name { |
| 104 | fn validate<'i>( |
| 105 | &self, |
| 106 | instance: &'i Value, |
| 107 | location: &LazyLocation, |
| 108 | ctx: &mut ValidationContext, |
| 109 | ) -> Result<(), ValidationError<'i>> { |
| 110 | if self.is_valid(instance, ctx) { |
| 111 | Ok(()) |
| 112 | } else { |
| 113 | Err(ValidationError::$error_fn( |
| 114 | self.location.clone(), |
| 115 | location.into(), |
| 116 | instance, |
| 117 | self.limit_val.clone(), |
| 118 | )) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | fn is_valid(&self, instance: &Value, _ctx: &mut ValidationContext) -> bool { |
| 123 | use fraction::BigFraction; |
| 124 | if let Value::Number(item) = instance { |
| 125 | // Try to parse instance as BigInt first |
| 126 | if let Some(instance_bigint) = numeric::bignum::try_parse_bigint(item) { |
| 127 | // Both are BigInt - direct comparison |
| 128 | instance_bigint $bigint_op self.limit |
| 129 | } else if let Some(v) = item.as_u64() { |
| 130 | $u64_cmp(v, &self.limit) |
| 131 | } else if let Some(v) = item.as_i64() { |
| 132 | $i64_cmp(v, &self.limit) |
| 133 | } else if let Some(v) = item.as_f64() { |
| 134 | $f64_cmp(v, &self.limit) |
| 135 | } else { |
| 136 | // Number doesn't fit in f64 (e.g., 1e1000) |
| 137 | // Since limit is BigInt, we need to compare with BigFraction |
| 138 | if let Some(instance_bigfrac) = numeric::bignum::try_parse_bigfraction(item) { |
| 139 | // Convert BigInt limit to BigFraction for comparison |
| 140 | // Use clone to avoid truncation through i128 |
| 141 | let limit_frac = BigFraction::from(self.limit.clone()); |
| 142 | instance_bigfrac $bigint_op limit_frac |
| 143 | } else { |
| 144 | // Can't parse as BigFraction - extremely large scientific notation |
| 145 | // (e.g., "1e10000" which exceeds BigFraction's parsing capability) |
| 146 | // These behave like positive/negative infinity for comparison purposes |
| 147 | let is_negative = item.as_str().starts_with('-'); |
| 148 | $infinity_fn(is_negative) |
| 149 | } |
| 150 | } |
| 151 | } else { |
| 152 | true |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | }; |
| 157 | } |
| 158 | |
| 159 | define_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigint_validator!!( |
| 160 | BigIntMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMinimum#, |
| 161 | u64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_ge_bigint()., |
| 162 | i64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_ge_bigint()., |
| 163 | f64_ge_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_ge_bigint()., |
| 164 | >=, |
| 165 | minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]minimum()., |
| 166 | |is_negative: bool| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_negative // For >= and >, positive infinity passes |
| 167 | ); |
| 168 | define_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigint_validator!!( |
| 169 | BigIntMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMaximum#, |
| 170 | u64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_le_bigint()., |
| 171 | i64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_le_bigint()., |
| 172 | f64_le_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_le_bigint()., |
| 173 | <=, |
| 174 | maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]maximum()., |
| 175 | |is_negative: bool| is_negative // For <= and <, negative infinity passes |
| 176 | ); |
| 177 | define_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigint_validator!!( |
| 178 | BigIntExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMinimum#, |
| 179 | u64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_gt_bigint()., |
| 180 | i64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_gt_bigint()., |
| 181 | f64_gt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_gt_bigint()., |
| 182 | >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt()., |
| 183 | exclusive_minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_minimum()., |
| 184 | |is_negative: bool| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_negative // For >= and >, positive infinity passes |
| 185 | ); |
| 186 | define_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigint_validator!!( |
| 187 | BigIntExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMaximum#, |
| 188 | u64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_lt_bigint()., |
| 189 | i64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_lt_bigint()., |
| 190 | f64_lt_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_lt_bigint()., |
| 191 | <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt()., |
| 192 | exclusive_maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_maximum()., |
| 193 | |is_negative: bool| is_negative // For <= and <, negative infinity passes |
| 194 | ); |
| 195 | |
| 196 | // BigFraction validators for arbitrary precision floats |
| 197 | use fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#; |
| 198 | |
| 199 | macro_rules! define_bigfrac_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigfrac_validator! { |
| 200 | ($struct_name:ident, $u64_cmp:path, $i64_cmp:path, $f64_cmp:path, $bigfrac_op:tt, $error_fn:ident) => { |
| 201 | #[derive(Debug, Clone, PartialEq)] |
| 202 | pub(crate) struct $struct_name { |
| 203 | pub(super) limit: BigFraction, |
| 204 | pub(super) limit_val: Value, |
| 205 | pub(super) location: Location, |
| 206 | } |
| 207 | |
| 208 | impl $struct_name { |
| 209 | pub(crate) fn new(limit: BigFraction, limit_val: Value, location: Location) -> Self { |
| 210 | Self { limit, limit_val, location } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | impl Validate for $struct_name { |
| 215 | fn validate<'i>( |
| 216 | &self, |
| 217 | instance: &'i Value, |
| 218 | location: &LazyLocation, |
| 219 | ctx: &mut ValidationContext, |
| 220 | ) -> Result<(), ValidationError<'i>> { |
| 221 | if self.is_valid(instance, ctx) { |
| 222 | Ok(()) |
| 223 | } else { |
| 224 | Err(ValidationError::$error_fn( |
| 225 | self.location.clone(), |
| 226 | location.into(), |
| 227 | instance, |
| 228 | self.limit_val.clone(), |
| 229 | )) |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | fn is_valid(&self, instance: &Value, _ctx: &mut ValidationContext) -> bool { |
| 234 | if let Value::Number(item) = instance { |
| 235 | // Try to parse instance as BigFraction for exact precision |
| 236 | if let Some(instance_bigfrac) = try_parse_bigfraction(item) { |
| 237 | // Both are BigFraction - direct comparison |
| 238 | instance_bigfrac $bigfrac_op self.limit |
| 239 | } else if let Some(v) = item.as_u64() { |
| 240 | $u64_cmp(v, &self.limit) |
| 241 | } else if let Some(v) = item.as_i64() { |
| 242 | $i64_cmp(v, &self.limit) |
| 243 | } else if let Some(v) = item.as_f64() { |
| 244 | // Scientific notation or other f64-representable numbers |
| 245 | $f64_cmp(v, &self.limit) |
| 246 | } else { |
| 247 | // Extreme scientific notation beyond f64 range (e.g., 1e309, 1e400) |
| 248 | // These are not supported for comparison - treat as always valid |
| 249 | // since we can't reliably compare them |
| 250 | true |
| 251 | } |
| 252 | } else { |
| 253 | true |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | }; |
| 258 | } |
| 259 | |
| 260 | define_bigfrac_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigfrac_validator!!( |
| 261 | BigFracMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMinimum#, |
| 262 | u64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_ge_bigfrac()., |
| 263 | i64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_ge_bigfrac()., |
| 264 | f64_ge_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_ge_bigfrac()., |
| 265 | >=, |
| 266 | minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]minimum(). |
| 267 | ); |
| 268 | define_bigfrac_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigfrac_validator!!( |
| 269 | BigFracMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMaximum#, |
| 270 | u64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_le_bigfrac()., |
| 271 | i64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_le_bigfrac()., |
| 272 | f64_le_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_le_bigfrac()., |
| 273 | <=, |
| 274 | maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]maximum(). |
| 275 | ); |
| 276 | define_bigfrac_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigfrac_validator!!( |
| 277 | BigFracExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMinimum#, |
| 278 | u64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_gt_bigfrac()., |
| 279 | i64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_gt_bigfrac()., |
| 280 | f64_gt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_gt_bigfrac()., |
| 281 | >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt()., |
| 282 | exclusive_minimumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_minimum(). |
| 283 | ); |
| 284 | define_bigfrac_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/define_bigfrac_validator!!( |
| 285 | BigFracExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMaximum#, |
| 286 | u64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/u64_lt_bigfrac()., |
| 287 | i64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/i64_lt_bigfrac()., |
| 288 | f64_lt_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/f64_lt_bigfrac()., |
| 289 | <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt()., |
| 290 | exclusive_maximumrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]exclusive_maximum(). |
| 291 | ); |
| 292 | } |
| 293 | |
| 294 | #[inline] |
| 295 | fn create_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_validator().<T, V>( |
| 296 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 297 | keyword: &str, |
| 298 | limit: T, |
| 299 | schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 300 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'static> |
| 301 | where |
| 302 | V: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(T, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#)> + Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# + 'static, |
| 303 | { |
| 304 | 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().(keyword); |
| 305 | 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().(V::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().((limit, schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), location)))) |
| 306 | } |
| 307 | |
| 308 | fn number_type_errorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/number_type_error().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 309 | 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().( |
| 310 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(), |
| 311 | 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().(), |
| 312 | schema, |
| 313 | JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Numberrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Number#, |
| 314 | )) |
| 315 | } |
| 316 | |
| 317 | macro_rules! create_numeric_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_numeric_validator! { |
| 318 | ($validator_type:ident, $ctx:expr, $keyword:expr, $limit:expr, $schema:expr) => { |
| 319 | if let Some(limit) = $limit.as_u64() { |
| 320 | Some(create_validator::<_, $validator_type<u64>>( |
| 321 | $ctx, $keyword, limit, $schema, |
| 322 | )) |
| 323 | } else if let Some(limit) = $limit.as_i64() { |
| 324 | Some(create_validator::<_, $validator_type<i64>>( |
| 325 | $ctx, $keyword, limit, $schema, |
| 326 | )) |
| 327 | } else { |
| 328 | #[cfg(feature = "arbitrary-precision")] |
| 329 | { |
| 330 | if let Some(result) = create_bigint_validator($ctx, $keyword, $limit, $schema) { |
| 331 | return Some(result); |
| 332 | } |
| 333 | } |
| 334 | // Handle numbers that don't fit in f64 (e.g., 1e10000) |
| 335 | // These are extremely large scientific notation numbers |
| 336 | if let Some(limit_f64) = $limit.as_f64() { |
| 337 | Some(create_validator::<_, $validator_type<f64>>( |
| 338 | $ctx, $keyword, limit_f64, $schema, |
| 339 | )) |
| 340 | } else { |
| 341 | #[cfg(feature = "arbitrary-precision")] |
| 342 | { |
| 343 | // Number is too large for f64 and couldn't be parsed as BigInt/BigFraction |
| 344 | // (e.g., "1e10000" with huge exponent exceeding f64 range) |
| 345 | // Use actual infinity as the comparison limit based on sign |
| 346 | let is_negative = $limit.as_str().starts_with('-'); |
| 347 | let infinity_limit = if is_negative { |
| 348 | f64::NEG_INFINITY |
| 349 | } else { |
| 350 | f64::INFINITY |
| 351 | }; |
| 352 | Some(create_validator::<_, $validator_type<f64>>( |
| 353 | $ctx, |
| 354 | $keyword, |
| 355 | infinity_limit, |
| 356 | $schema, |
| 357 | )) |
| 358 | } |
| 359 | #[cfg(not(feature = "arbitrary-precision"))] |
| 360 | { |
| 361 | unreachable!("as_f64() always returns Some without arbitrary-precision") |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | }; |
| 366 | } |
| 367 | |
| 368 | #[cfg(feature = "arbitrary-precision")] |
| 369 | fn create_bigint_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_bigint_validator().( |
| 370 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 371 | keyword: &str, |
| 372 | limit: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#, |
| 373 | schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 374 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'static>> { |
| 375 | use bigint_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/::{ |
| 376 | BigFracExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMaximum#, BigFracExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMinimum#, BigFracMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMaximum#, BigFracMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMinimum#, |
| 377 | BigIntExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMaximum#, BigIntExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMinimum#, BigIntMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMaximum#, BigIntMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMinimum#, |
| 378 | }; |
| 379 | |
| 380 | // Try BigInt first for large integers |
| 381 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bigint_limit) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigint().(limit) { |
| 382 | 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().(keyword); |
| 383 | let validator: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#> = match keyword { |
| 384 | "minimum" => 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().(BigIntMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMinimum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigIntMinimum]new().(bigint_limit, schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), location)), |
| 385 | "maximum" => 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().(BigIntMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntMaximum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigIntMaximum]new().(bigint_limit, schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), location)), |
| 386 | "exclusiveMinimum" => 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().(BigIntExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMinimum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigIntExclusiveMinimum]new().( |
| 387 | bigint_limit, |
| 388 | schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), |
| 389 | location, |
| 390 | )), |
| 391 | "exclusiveMaximum" => 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().(BigIntExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigIntExclusiveMaximum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigIntExclusiveMaximum]new().( |
| 392 | bigint_limit, |
| 393 | schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), |
| 394 | location, |
| 395 | )), |
| 396 | _ => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 397 | }; |
| 398 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(validator)); |
| 399 | } |
| 400 | |
| 401 | // If not a BigInt, try BigFraction for exact decimal precision |
| 402 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bigfrac_limit) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigfractionrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigfraction().(limit) { |
| 403 | 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().(keyword); |
| 404 | let validator: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#> = match keyword { |
| 405 | "minimum" => 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().(BigFracMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMinimum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigFracMinimum]new().(bigfrac_limit, schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), location)), |
| 406 | "maximum" => 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().(BigFracMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracMaximum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigFracMaximum]new().(bigfrac_limit, schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), location)), |
| 407 | "exclusiveMinimum" => 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().(BigFracExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMinimum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigFracExclusiveMinimum]new().( |
| 408 | bigfrac_limit, |
| 409 | schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), |
| 410 | location, |
| 411 | )), |
| 412 | "exclusiveMaximum" => 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().(BigFracExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/BigFracExclusiveMaximum#::newrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/bigint_validators/impl#[BigFracExclusiveMaximum]new().( |
| 413 | bigfrac_limit, |
| 414 | schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(), |
| 415 | location, |
| 416 | )), |
| 417 | _ => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 418 | }; |
| 419 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(validator)); |
| 420 | } |
| 421 | |
| 422 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 423 | } |
| 424 | |
| 425 | #[inline] |
| 426 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_minimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/compile_minimum().<'a>( |
| 427 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 428 | _: &'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#>, |
| 429 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 430 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 431 | match schema { |
| 432 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(limit) => create_numeric_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_numeric_validator!!(Minimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/Minimum#, ctx, "minimum", limit, schema), |
| 433 | _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(number_type_errorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/number_type_error().(ctx, schema)), |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | #[inline] |
| 438 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_maximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/compile_maximum().<'a>( |
| 439 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 440 | _: &'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#>, |
| 441 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 442 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 443 | match schema { |
| 444 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(limit) => create_numeric_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_numeric_validator!!(Maximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/Maximum#, ctx, "maximum", limit, schema), |
| 445 | _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(number_type_errorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/number_type_error().(ctx, schema)), |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | #[inline] |
| 450 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_exclusive_minimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/compile_exclusive_minimum().<'a>( |
| 451 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 452 | _: &'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#>, |
| 453 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 454 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 455 | match schema { |
| 456 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(limit) => { |
| 457 | create_numeric_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_numeric_validator!!(ExclusiveMinimumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/ExclusiveMinimum#, ctx, "exclusiveMinimum", limit, schema) |
| 458 | } |
| 459 | _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(number_type_errorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/number_type_error().(ctx, schema)), |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | #[inline] |
| 464 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_exclusive_maximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/compile_exclusive_maximum().<'a>( |
| 465 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 466 | _: &'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#>, |
| 467 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 468 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 469 | match schema { |
| 470 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(limit) => { |
| 471 | create_numeric_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/create_numeric_validator!!(ExclusiveMaximumrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/ExclusiveMaximum#, ctx, "exclusiveMaximum", limit, schema) |
| 472 | } |
| 473 | _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(number_type_errorrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/number_type_error().(ctx, schema)), |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | #[cfg(test)] |
| 478 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/ { |
| 479 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 480 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 481 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 482 | |
| 483 | #[cfg(feature = "arbitrary-precision")] |
| 484 | fn parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(json: &str) -> Valuerust-analyzer cargo serde_json 1.0.145 value/Value# { |
| 485 | serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::from_strrust-analyzer cargo serde_json 1.0.145 de/from_str().(json).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 486 | } |
| 487 | |
| 488 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_u64 << 54) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). 1))] |
| 489 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_i64 << 54) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). 1))] |
| 490 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_u64 << 54) +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). 1))] |
| 491 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_i64 << 54) +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). 1))] |
| 492 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1_u64 << 54))] |
| 493 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1_i64 << 54))] |
| 494 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_u64 << 54) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). 1))] |
| 495 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_i64 << 54) -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). 1))] |
| 496 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1_u64 << 54))] |
| 497 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1_i64 << 54))] |
| 498 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": 1_u64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_u64 << 54) +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). 1))] |
| 499 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": 1_i64 << 54}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!((1_i64 << 54) +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). 1))] |
| 500 | fn is_not_validrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/is_not_valid().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) { |
| 501 | 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, instance); |
| 502 | } |
| 503 | |
| 504 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/minimum")] |
| 505 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 6}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/minimum")] |
| 506 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 7}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/minimum")] |
| 507 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(10), "/maximum")] |
| 508 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 6}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(10), "/maximum")] |
| 509 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 7}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(10), "/maximum")] |
| 510 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/exclusiveMinimum")] |
| 511 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 6}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/exclusiveMinimum")] |
| 512 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMinimum": 7}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/exclusiveMinimum")] |
| 513 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": 5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(7), "/exclusiveMaximum")] |
| 514 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(7), "/exclusiveMaximum")] |
| 515 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"exclusiveMaximum": -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(7), "/exclusiveMaximum")] |
| 516 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/location().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &str) { |
| 517 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(schema, instance, expected); |
| 518 | } |
| 519 | |
| 520 | // Tests for arbitrary-precision feature - valid cases |
| 521 | #[cfg(feature = "arbitrary-precision")] |
| 522 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, r"18446744073709551617"; "minimum valid above u64_max")] |
| 523 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -9223372036854775809}"#, r"-9223372036854775808"; "minimum valid below i64_min")] |
| 524 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, r"18446744073709551615"; "maximum valid below limit")] |
| 525 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 18446744073709551616}"#, r"18446744073709551617"; "exclusive_minimum valid")] |
| 526 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 18446744073709551616}"#, r"18446744073709551615"; "exclusive_maximum valid")] |
| 527 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e20"; "scientific notation above bigint minimum")] |
| 528 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e15"; "scientific notation below bigint maximum")] |
| 529 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0}"#, "1e1000"; "minimum with huge positive number")] |
| 530 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -1e100}"#, "1e1000"; "minimum with huge positive above limit")] |
| 531 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 0}"#, "1e1000"; "exclusive minimum with huge positive")] |
| 532 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e20"; "bigint minimum with huge instance valid")] |
| 533 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e15"; "bigint maximum with huge instance valid")] |
| 534 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 18446744073709551616}"#, "1e25"; "bigint exclusive minimum with huge instance valid")] |
| 535 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0}"#, "1e10000"; "infinity positive above minimum")] |
| 536 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0}"#, "-1e10000"; "infinity negative below maximum")] |
| 537 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -100}"#, "1e10000"; "infinity positive above negative minimum")] |
| 538 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 100}"#, "-1e10000"; "infinity negative below positive maximum")] |
| 539 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e10000"; "infinity above bigint minimum")] |
| 540 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "-1e10000"; "infinity below bigint maximum")] |
| 541 | fn is_valid_arbitrary_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/is_valid_arbitrary_precision().(schema_json: &str, instance_json: &str) { |
| 542 | let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(schema_json); |
| 543 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(instance_json); |
| 544 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance); |
| 545 | } |
| 546 | |
| 547 | // Tests for arbitrary-precision feature - invalid cases |
| 548 | #[cfg(feature = "arbitrary-precision")] |
| 549 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, r"18446744073709551615"; "minimum invalid at u64_max")] |
| 550 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, r"18446744073709551617"; "maximum invalid above limit")] |
| 551 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 18446744073709551616}"#, r"18446744073709551616"; "exclusive_minimum invalid at boundary")] |
| 552 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 18446744073709551616}"#, r"18446744073709551617"; "exclusive_maximum invalid above limit")] |
| 553 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e10"; "scientific notation below bigint minimum")] |
| 554 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e25"; "scientific notation above bigint maximum")] |
| 555 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 1e100}"#, "1e1000"; "maximum with huge number above limit")] |
| 556 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 1e100}"#, "1e1000"; "exclusive maximum with huge number")] |
| 557 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1e100}"#, "-1e1000"; "minimum with huge negative below limit")] |
| 558 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e10"; "bigint minimum with huge instance invalid")] |
| 559 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e25"; "bigint maximum with huge instance invalid")] |
| 560 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 18446744073709551616}"#, "1e25"; "bigint exclusive maximum with huge instance invalid")] |
| 561 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0}"#, "1e10000"; "infinity positive above maximum")] |
| 562 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0}"#, "-1e10000"; "infinity negative below minimum")] |
| 563 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 100}"#, "1e10000"; "infinity positive above exclusive maximum")] |
| 564 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": -100}"#, "-1e10000"; "infinity negative below exclusive minimum")] |
| 565 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e10000"; "infinity above bigint maximum")] |
| 566 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "-1e10000"; "infinity below bigint minimum")] |
| 567 | fn is_not_valid_arbitrary_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/is_not_valid_arbitrary_precision().(schema_json: &str, instance_json: &str) { |
| 568 | let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(schema_json); |
| 569 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(instance_json); |
| 570 | 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, &instance); |
| 571 | } |
| 572 | |
| 573 | // Regression test for BigInt limits exceeding i128 range with fractional instances |
| 574 | #[cfg(feature = "arbitrary-precision")] |
| 575 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 576 | fn bigint_limit_exceeds_i128_with_fractionrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/bigint_limit_exceeds_i128_with_fraction().() { |
| 577 | // 10^50 is way beyond i128::MAX (~1.7e38) |
| 578 | let limit = "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(50); |
| 579 | let schema_min = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"{{"minimum": {limit}}}"#)); |
| 580 | |
| 581 | // Instance slightly below limit (10^50 - 1), should be INVALID |
| 582 | let instance_below = "9".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"9".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(49); |
| 583 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(&instance_below); |
| 584 | 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_min, &instance); |
| 585 | |
| 586 | // Instance equal to limit, should be VALID |
| 587 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(&limit); |
| 588 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema_min, &instance); |
| 589 | |
| 590 | // Test maximum as well |
| 591 | let schema_max = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"{{"maximum": {limit}}}"#)); |
| 592 | |
| 593 | // Instance slightly above limit (10^50 + 1), should be INVALID |
| 594 | let instance_above = "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(50) rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add()."1"; |
| 595 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(&instance_above); |
| 596 | 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_max, &instance); |
| 597 | } |
| 598 | |
| 599 | // Test that schema compilation doesn't panic with extremely large scientific notation limits |
| 600 | // These numbers (e.g., 1e10000) exceed f64 range and are treated as infinity for comparison |
| 601 | #[cfg(feature = "arbitrary-precision")] |
| 602 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1e10000}"#, "999999999999"; "huge positive scientific notation minimum")] |
| 603 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 1e10000}"#, "999999999999"; "huge positive scientific notation maximum")] |
| 604 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -1e10000}"#, "999999999999"; "huge negative scientific notation minimum")] |
| 605 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -1e10000}"#, "999999999999"; "huge negative scientific notation maximum")] |
| 606 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 1e10000}"#, "999999999999"; "huge positive scientific notation exclusive minimum")] |
| 607 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 1e10000}"#, "999999999999"; "huge positive scientific notation exclusive maximum")] |
| 608 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": -1e10000}"#, "999999999999"; "huge negative scientific notation exclusive minimum")] |
| 609 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": -1e10000}"#, "999999999999"; "huge negative scientific notation exclusive maximum")] |
| 610 | fn extreme_scientific_notation_schema_limits_no_panicrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/extreme_scientific_notation_schema_limits_no_panic().(schema_json: &str, instance_json: &str) { |
| 611 | // This test ensures compilation doesn't panic when schema limits exceed f64 range |
| 612 | let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(schema_json); |
| 613 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(instance_json); |
| 614 | // The actual validation result doesn't matter - we're just ensuring no panic |
| 615 | let compiled = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema); |
| 616 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(compiled.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().(), "Schema compilation should not panic"); |
| 617 | |
| 618 | // Also verify validation works |
| 619 | let validator = compiled.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 620 | let _ = validator.is_validrust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]is_valid().(&instance); |
| 621 | } |
| 622 | |
| 623 | // Test validation behavior with extremely large scientific notation schema limits |
| 624 | #[cfg(feature = "arbitrary-precision")] |
| 625 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1e10000}"#, "999999999999", false; "normal number vs huge positive minimum")] |
| 626 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 1e10000}"#, "999999999999", true; "normal number vs huge positive maximum")] |
| 627 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -1e10000}"#, "999999999999", true; "normal number vs huge negative minimum")] |
| 628 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -1e10000}"#, "999999999999", false; "normal number vs huge negative maximum")] |
| 629 | fn extreme_scientific_notation_schema_limits_validationrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/extreme_scientific_notation_schema_limits_validation().( |
| 630 | schema_json: &str, |
| 631 | instance_json: &str, |
| 632 | expected_valid: bool, |
| 633 | ) { |
| 634 | let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(schema_json); |
| 635 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/minmax/tests/parse_json().(instance_json); |
| 636 | if expected_valid { |
| 637 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance); |
| 638 | } else { |
| 639 | 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, &instance); |
| 640 | } |
| 641 | } |
| 642 | } |