#[non_exhaustive]pub struct ValidationIssue {
pub severity: Severity,
pub code: IssueCode,
pub message: String,
pub span: Option<Span>,
pub suggestion: Option<String>,
pub command: Option<String>,
}Expand description
A validation issue found in the script.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.severity: SeveritySeverity level.
code: IssueCodeIssue category code.
message: StringHuman-readable message.
span: Option<Span>Optional source location.
suggestion: Option<String>Optional suggestion for fixing the issue.
command: Option<String>The command this issue concerns, when one is genuinely known.
Some(name) when a name is on hand: a builtin’s own Tool::validate
raising about itself, a schema-driven argument issue (the schema’s
name), a wrapped command’s refusal, UndefinedCommand’s unresolved
name, scatter without a gather, and a user tool’s arity failure.
None, never a placeholder, when the issue is not about a command at
all — an assignment target, a bare break, an undefined variable, or
MixedScriptName, where the mis-spelled name is the argument.
Severity varies: UndefinedCommand is a Warning and so never reaches
KernelError::Validation, which kaish-kernel filters to Error.
Reading it means driving the Validator directly.
One limit: schema-driven issues record the SCHEMA’s name, which equals the invoked name for every builtin (pinned by a registry test) but is not enforced for a tool an embedder registers.
Route on code, then narrow by command; don’t parse message to
recover a name this field already gives you.
Implementations§
Source§impl ValidationIssue
impl ValidationIssue
Sourcepub fn error(code: IssueCode, message: impl Into<String>) -> Self
pub fn error(code: IssueCode, message: impl Into<String>) -> Self
Create a new validation error.
Sourcepub fn warning(code: IssueCode, message: impl Into<String>) -> Self
pub fn warning(code: IssueCode, message: impl Into<String>) -> Self
Create a new validation warning.
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Add a suggestion to this issue.
Sourcepub fn with_command(self, command: impl Into<String>) -> Self
pub fn with_command(self, command: impl Into<String>) -> Self
Record the command this issue concerns.
Call this only where the name is genuinely known at the construction
site — the tool being validated, or the unresolved name itself for
UndefinedCommand. Leave it unset rather than guess.
Trait Implementations§
Source§impl Clone for ValidationIssue
impl Clone for ValidationIssue
Source§fn clone(&self) -> ValidationIssue
fn clone(&self) -> ValidationIssue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more