Add simplistic config validation

This commit is contained in:
Lukas Wirth 2022-04-11 13:10:43 +02:00
parent 6d7055e322
commit b90df7997d

View File

@ -571,6 +571,9 @@ impl Config {
None => tracing::info!("Invalid snippet {}", name),
}
}
self.validate(&mut errors);
if errors.is_empty() {
Ok(())
} else {
@ -578,6 +581,16 @@ impl Config {
}
}
fn validate(&self, error_sink: &mut Vec<(String, serde_json::Error)>) {
use serde::de::Error;
if self.data.checkOnSave_command.is_empty() {
error_sink.push((
"/checkOnSave/command".to_string(),
serde_json::Error::custom("expected a non-empty string"),
));
}
}
pub fn json_schema() -> serde_json::Value {
ConfigData::json_schema()
}