implement validate for bearcaps
This commit is contained in:
parent
64e670480a
commit
a5b097bce5
1 changed files with 9 additions and 0 deletions
|
@ -4,6 +4,7 @@ use std::iter::Peekable;
|
|||
use std::str::Chars;
|
||||
|
||||
use crate::core::*;
|
||||
use crate::util::validate::{ResultBuilder, Validate};
|
||||
|
||||
const MAX_PARAM_LEN: usize = 16384;
|
||||
|
||||
|
@ -133,6 +134,14 @@ impl<'de> de::Visitor<'de> for BearcapVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Validate for Bearcap {
|
||||
fn validate(&self, builder: ResultBuilder) -> ResultBuilder {
|
||||
builder.field(&self.url, "url", |f| {
|
||||
f.check("URL must start with https://", |v| v.starts_with("https://"))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::util::bear::Bearcap;
|
||||
|
|
Loading…
Reference in a new issue