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
1 changed files with 14 additions and 0 deletions

View File

@ -141,6 +141,8 @@ impl StringSchema {
pub struct ArraySchema { pub struct ArraySchema {
pub description: &'static str, pub description: &'static str,
pub items: Arc<Schema>, pub items: Arc<Schema>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
} }
impl ArraySchema { impl ArraySchema {
@ -149,8 +151,20 @@ impl ArraySchema {
ArraySchema { ArraySchema {
description: description, description: description,
items: item_schema, 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)] #[derive(Debug)]