validate_suggestion

Function validate_suggestion 

Source
pub fn validate_suggestion(suggestion: &str, prefix: &str) -> Option<String>
Expand description

Validate and clean a suggestion before returning to user.

Returns None if the suggestion is invalid or malformed.

§Arguments

  • suggestion - The raw suggestion from the model
  • prefix - The user’s input prefix

§Example

use aprender_shell::quality::validate_suggestion;

assert!(validate_suggestion("git status", "git").is_some());
assert!(validate_suggestion("git", "git").is_none()); // Not longer than prefix
assert!(validate_suggestion("git status \\", "git").is_none()); // Trailing backslash