added limit 1 to arrays treated as a single value in schemas

This commit is contained in:
2026-07-16 13:43:08 -04:00
parent 1fedf5253c
commit c4bf6bde58
47 changed files with 616 additions and 586 deletions

View File

@ -1,4 +1,5 @@
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use indexmap::IndexMap;
use serde_json::Value;
@ -18,7 +19,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "MIN_ITEMS_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("count".to_string(), arr.len().to_string()),
("limit".to_string(), min.to_string()),
])),
@ -30,7 +31,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "MAX_ITEMS_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("count".to_string(), arr.len().to_string()),
("limit".to_string(), max.to_string()),
])),
@ -77,7 +78,7 @@ impl<'a> ValidationContext<'a> {
if _match_count < min {
result.errors.push(ValidationError {
code: "CONTAINS_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("count".to_string(), _match_count.to_string()),
("limit".to_string(), min.to_string()),
])),
@ -89,7 +90,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "CONTAINS_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("count".to_string(), _match_count.to_string()),
("limit".to_string(), max.to_string()),
])),