Add simplistic config validation
This commit is contained in:
@@ -571,6 +571,9 @@ impl Config {
|
|||||||
None => tracing::info!("Invalid snippet {}", name),
|
None => tracing::info!("Invalid snippet {}", name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.validate(&mut errors);
|
||||||
|
|
||||||
if errors.is_empty() {
|
if errors.is_empty() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} 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 {
|
pub fn json_schema() -> serde_json::Value {
|
||||||
ConfigData::json_schema()
|
ConfigData::json_schema()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user