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

Method from_directive

aiscript-directive/src/validator/format.rs:193–210  ·  view source on GitHub ↗
(directive: Directive)

Source from the content-addressed store, hash-verified

191// The FromDirective implementation remains the same
192impl FromDirective for FormatValidator {
193 fn from_directive(directive: Directive) -> Result<Self, String> {
194 // Same implementation as before
195 match directive.params {
196 DirectiveParams::KeyValue(params) => {
197 match params.get("type").and_then(|v| v.as_str()) {
198 Some(format_type) => match format_type {
199 "email" | "url" | "uuid" | "ipv4" | "ipv6" | "date" | "datetime"
200 | "time" | "month" | "week" | "color" => Ok(Self {
201 format_type: format_type.to_string(),
202 }),
203 _ => Err(format!("Unsupported format type: {}", format_type)),
204 },
205 None => Err("@format directive requires a 'type' parameter".into()),
206 }
207 }
208 _ => Err("Invalid params for @format directive".into()),
209 }
210 }
211}
212
213#[cfg(test)]

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected