Skip to main content

Validator

Struct Validator 

Source
pub struct Validator { /* private fields */ }
Expand description

Implements an AST validator.

A validator operates on a set of AST visitors.

See the validate method to perform the validation.

Implementations§

Source§

impl Validator

Source

pub fn empty() -> Self

Creates a validator with an empty visitors set.

Source

pub fn add_visitor<V: Visitor + 'static>(&mut self, visitor: V)

Adds a visitor to the validator.

Source

pub fn add_visitors( &mut self, visitors: impl IntoIterator<Item = Box<dyn Visitor>>, )

Adds multiple visitors to the validator.

Source

pub fn extend_known_rules(&mut self, rules: impl IntoIterator<Item = String>)

Adds rule names to the validator’s known rules set.

Source

pub fn validate( &mut self, document: &Document, config: &Config, ) -> Result<(), Diagnostics>

Validates the given document and returns the validation errors upon failure.

Source

pub fn find_nearest_rule(&self, unknown_rule_id: &str) -> Option<String>

Finds the nearest known rule ID to the given unknown rule ID, or None if no rule ID is close enough.

Trait Implementations§

Source§

impl Default for Validator

Source§

fn default() -> Self

Creates a validator with the default validation visitors.

Source§

impl Visitor for Validator

Source§

fn known_rules(&self) -> HashSet<String>

Get all lint rules known to this Visitor. Read more
Source§

fn register(&mut self, config: &Config)

Registers configuration with a visitor.
Source§

fn reset(&mut self)

Resets the visitor to its initial state. Read more
Source§

fn document( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, doc: &Document, version: SupportedVersion, )

Visits the root document node.
Source§

fn whitespace(&mut self, diagnostics: &mut Diagnostics, whitespace: &Whitespace)

Visits a whitespace token.
Source§

fn comment(&mut self, diagnostics: &mut Diagnostics, comment: &Comment)

Visit a comment token.
Source§

fn version_statement( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, stmt: &VersionStatement, )

Visits a top-level version statement node.
Source§

fn import_statement( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, stmt: &ImportStatement, )

Visits a top-level import statement node.
Source§

fn struct_definition( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, def: &StructDefinition, )

Visits a struct definition node.
Source§

fn enum_definition( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, def: &EnumDefinition, )

Visits an enum definition node.
Source§

fn task_definition( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, task: &TaskDefinition, )

Visits a task definition node.
Source§

fn workflow_definition( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, workflow: &WorkflowDefinition, )

Visits a workflow definition node.
Source§

fn input_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &InputSection, )

Visits an input section node.
Source§

fn output_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &OutputSection, )

Visits an output section node.
Source§

fn command_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &CommandSection, )

Visits a command section node.
Source§

fn command_text(&mut self, diagnostics: &mut Diagnostics, text: &CommandText)

Visits a command text token in a command section node.
Source§

fn requirements_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &RequirementsSection, )

Visits a requirements section node.
Source§

fn task_hints_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &TaskHintsSection, )

Visits a task hints section node.
Source§

fn workflow_hints_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &WorkflowHintsSection, )

Visits a workflow hints section node.
Source§

fn runtime_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &RuntimeSection, )

Visits a runtime section node.
Source§

fn runtime_item( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, item: &RuntimeItem, )

Visits a runtime item node.
Source§

fn metadata_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &MetadataSection, )

Visits a metadata section node.
Source§

fn parameter_metadata_section( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, section: &ParameterMetadataSection, )

Visits a parameter metadata section node.
Source§

fn metadata_object( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, object: &MetadataObject, )

Visits a metadata object in a metadata or parameter metadata section.
Source§

fn metadata_object_item( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, item: &MetadataObjectItem, )

Visits a metadata object item in a metadata object.
Source§

fn metadata_array( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, item: &MetadataArray, )

Visits a metadata array node in a metadata or parameter metadata section.
Source§

fn unbound_decl( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, decl: &UnboundDecl, )

Visits an unbound declaration node.
Source§

fn bound_decl( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, decl: &BoundDecl, )

Visits a bound declaration node.
Source§

fn expr( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, expr: &Expr, )

Visits an expression node.
Source§

fn string_text(&mut self, diagnostics: &mut Diagnostics, text: &StringText)

Visits a string text token in a literal string node.
Source§

fn placeholder( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, placeholder: &Placeholder, )

Visits a placeholder node.
Source§

fn conditional_statement( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, stmt: &ConditionalStatement, )

Visits a conditional statement node in a workflow.
Source§

fn scatter_statement( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, stmt: &ScatterStatement, )

Visits a scatter statement node in a workflow.
Source§

fn call_statement( &mut self, diagnostics: &mut Diagnostics, reason: VisitReason, stmt: &CallStatement, )

Visits a call statement node in a workflow.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more