added limit 1 to arrays treated as a single value in schemas
This commit is contained in:
@ -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()),
|
||||
])),
|
||||
|
||||
Reference in New Issue
Block a user