Validator

Trait Validator 

Source
pub trait Validator: Send + Sync {
    // Required methods
    fn validate(&self, kind: &SlotKind, code: &str) -> Result<ValidationResult>;
    fn format(&self, kind: &SlotKind, code: &str) -> Result<String>;

    // Provided method
    fn validate_with_slot(
        &self,
        _slot: &Slot,
        code: &str,
    ) -> Result<ValidationResult> { ... }
}
Expand description

Trait for implementing code validators and formatters.

Required Methods§

Source

fn validate(&self, kind: &SlotKind, code: &str) -> Result<ValidationResult>

Check if the code is valid according to the validator’s rules.

Source

fn format(&self, kind: &SlotKind, code: &str) -> Result<String>

Format the code to comply with style guides.

Provided Methods§

Source

fn validate_with_slot( &self, _slot: &Slot, code: &str, ) -> Result<ValidationResult>

Optional: Validate using the full slot context (for TDD).

Implementors§