pub struct FieldWhitelist {
allowed: &'static [&'static str],
}
impl FieldWhitelist {
pub fn new(allowed: &'static [&'static str]) -> Self {
Self { allowed }
}
pub fn check(&self, field: &str) -> Result<(), String> {
if !self.allowed.contains(&field) {
return Err(format!("Illegal field: {}", field));
}
Ok(())
}
}