implement validate for bearcaps

This commit is contained in:
anna 2022-12-20 14:09:19 +01:00
parent 64e670480a
commit a5b097bce5
Signed by: fef
GPG key ID: EC22E476DC2D3D84

View file

@ -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;