Skip to main content

validate_source

Function validate_source 

Source
pub fn validate_source(raw: &str) -> Result<&'static str, AppError>
Expand description

Validates a raw memories.source string against the CHECK constraint domain.

This is the runtime guard for callers that still take &str (legacy call-sites, FTS rows already in the database, deserialised JSON). The function returns the canonical slice on success and an AppError::Validation on failure, with an actionable message listing every accepted value.

Use this at every boundary that touches the source column: memories::insert, memories::update, and any new code path that builds a NewMemory from operator-supplied input. It is the safety net that prevented the original G29 bug from regressing in v1.0.69 when the typed MemorySource enum was still being rolled out.