(key: &str, length: usize, properties: &Properties)
| 872 | } |
| 873 | |
| 874 | fn validate_array_length(key: &str, length: usize, properties: &Properties) -> Result<()> { |
| 875 | if let Some(min) = properties.min_items { |
| 876 | if length < usize::try_from(min)? { |
| 877 | return Err(anyhow!( |
| 878 | "The array '{}' must have at least {} items, but got {}", |
| 879 | key, |
| 880 | min, |
| 881 | length |
| 882 | )); |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | if let Some(max) = properties.max_items { |
| 887 | if length > usize::try_from(max)? { |
| 888 | return Err(anyhow!( |
| 889 | "The array '{}' must have at most {} items, but got {}", |
| 890 | key, |
| 891 | max, |
| 892 | length |
| 893 | )); |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | Ok(()) |
| 898 | } |
| 899 | |
| 900 | fn format_error(kind: &str, key: &str, value: &str) -> anyhow::Error { |
| 901 | anyhow::anyhow!( |
no outgoing calls
no test coverage detected