MCPcopy Create free account
hub / github.com/Botloader/botloader / validate_script_meta

Function validate_script_meta

components/runtime/src/lib.rs:264–296  ·  view source on GitHub ↗
(meta: &ScriptMeta)

Source from the content-addressed store, hash-verified

262}
263
264pub(crate) fn validate_script_meta(meta: &ScriptMeta) -> Result<(), anyhow::Error> {
265 let mut out_buf = String::new();
266
267 for command in &meta.commands {
268 if let Err(verrs) = validation::validate(command, &()) {
269 for verr in verrs {
270 out_buf.push_str(format!("\ncommand {}: {}", command.name, verr).as_str());
271 }
272 }
273 }
274
275 for group in &meta.command_groups {
276 if let Err(verrs) = validation::validate(group, &()) {
277 for verr in verrs {
278 out_buf.push_str(format!("\ncommand group {}: {}", group.name, verr).as_str());
279 }
280 }
281 }
282
283 for option in &meta.settings {
284 if let Err(validation_errors) = validation::validate(option, &()) {
285 for error in validation_errors {
286 out_buf.push_str(format!("\nsettings options: {}", error).as_str());
287 }
288 }
289 }
290
291 if out_buf.is_empty() {
292 Ok(())
293 } else {
294 Err(anyhow::anyhow!("script validation failed: {}", out_buf))
295 }
296}
297
298pub fn try_insert_resource_table<T: deno_core::Resource>(
299 table: &mut ResourceTable,

Callers 1

Calls 1

validateFunction · 0.85

Tested by

no test coverage detected