MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / validate

Method validate

aiscript-directive/src/validator/regex.rs:18–32  ·  view source on GitHub ↗
(&self, value: &Value)

Source from the content-addressed store, hash-verified

16 }
17
18 fn validate(&self, value: &Value) -> Result<(), String> {
19 let value_str = match value.as_str() {
20 Some(s) => s,
21 None => return Err("Value must be a string".into()),
22 };
23
24 if self.pattern.is_match(value_str) {
25 Ok(())
26 } else {
27 Err(format!(
28 "Value does not match the regex pattern: {}",
29 self.raw_pattern
30 ))
31 }
32 }
33
34 fn as_any(&self) -> &dyn Any {
35 self

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected