ArraySchema: Add min_length and max_length

This commit is contained in:
Dietmar Maurer 2018-11-24 08:12:23 +01:00
parent 3e1497fb75
commit 757d9b4769

View File

@ -141,6 +141,8 @@ impl StringSchema {
pub struct ArraySchema {
pub description: &'static str,
pub items: Arc<Schema>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
}
impl ArraySchema {
@ -149,8 +151,20 @@ impl ArraySchema {
ArraySchema {
description: description,
items: item_schema,
min_length: None,
max_length: None,
}
}
pub fn min_length(mut self, min_length: usize) -> Self {
self.min_length = Some(min_length);
self
}
pub fn max_length(mut self, max_length: usize) -> Self {
self.max_length = Some(max_length);
self
}
}
#[derive(Debug)]