Skip to main content

validate_and_save

Function validate_and_save 

Source
pub fn validate_and_save(path: &Path, content: &str) -> Result<()>
Expand description

Validate bean content and persist it to disk with updated timestamp.

Parses the content using Bean::from_string() to validate the YAML schema. If validation succeeds, writes the content to the file and updates the updated_at field to the current UTC time.

§Arguments

  • path - Path where the validated content will be written
  • content - The edited bean content (YAML or Markdown with YAML frontmatter)

§Returns

  • Ok(()) if validation succeeds and file is written
  • Err with descriptive message if:
    • Content fails YAML schema validation
    • File I/O error occurs

§Examples

validate_and_save(Path::new(".beans/1-my-task.md"), edited_content)?;