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,4 @@
use std::collections::HashMap;
use indexmap::IndexMap;
use crate::validator::context::ValidationContext;
use crate::validator::error::ValidationError;
@ -16,7 +16,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "MINIMUM_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("value".to_string(), num.to_string()),
("limit".to_string(), min.to_string()),
])),
@ -28,7 +28,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "MAXIMUM_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("value".to_string(), num.to_string()),
("limit".to_string(), max.to_string()),
])),
@ -40,7 +40,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "EXCLUSIVE_MINIMUM_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("value".to_string(), num.to_string()),
("limit".to_string(), ex_min.to_string()),
])),
@ -52,7 +52,7 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "EXCLUSIVE_MAXIMUM_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("value".to_string(), num.to_string()),
("limit".to_string(), ex_max.to_string()),
])),
@ -64,7 +64,7 @@ impl<'a> ValidationContext<'a> {
if (val - val.round()).abs() > f64::EPSILON {
result.errors.push(ValidationError {
code: "MULTIPLE_OF_VIOLATED".to_string(),
values: Some(HashMap::from([
values: Some(IndexMap::from([
("value".to_string(), num.to_string()),
("multiple_of".to_string(), multiple_of.to_string()),
])),