20 lines
440 B
Rust
20 lines
440 B
Rust
|
use std::ops::Deref;
|
||
|
|
||
|
use crate::{InputType, InputValueError};
|
||
|
|
||
|
pub async fn min_items<T: Deref<Target = [E]> + InputType, E>(
|
||
|
value: &T,
|
||
|
len: usize,
|
||
|
) -> Result<(), InputValueError<T>> {
|
||
|
if value.deref().len() >= len {
|
||
|
Ok(())
|
||
|
} else {
|
||
|
Err(format!(
|
||
|
"the value length is {}, must be greater than or equal to {}",
|
||
|
value.deref().len(),
|
||
|
len
|
||
|
)
|
||
|
.into())
|
||
|
}
|
||
|
}
|