Skip to main content

ValidationOutcome

Enum ValidationOutcome 

Source
#[non_exhaustive]
pub enum ValidationOutcome { Valid, Invalid(Vec<Violation>), Skipped { reason: SkipReason, prerequisites: Vec<FailureId>, }, }
Expand description

The observable result of executing one bound validator occurrence.

§Examples

use qubit_validator::{ValidationOutcome, ValidatorId, Violation, ViolationCode};

let accepted = ValidationOutcome::valid();
let rejected = ValidationOutcome::invalid(vec![Violation::new(
    ValidatorId::new("text.required"),
    ViolationCode::new("text.blank"),
)])?;
assert!(matches!(accepted, ValidationOutcome::Valid));
assert!(matches!(rejected, ValidationOutcome::Invalid(violations) if violations.len() == 1));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Valid

Input is valid.

§

Invalid(Vec<Violation>)

Input is invalid.

Tuple Fields

§0: Vec<Violation>

One or more safe violations carrying no raw rejected value.

§

Skipped

Execution was skipped by the caller’s orchestration policy.

Fields

§reason: SkipReason

Reason for skipping.

§prerequisites: Vec<FailureId>

IDs of failures already retained in the same report.

Implementations§

Source§

impl ValidationOutcome

Source

pub const fn valid() -> Self

Creates a successful validation outcome.

§Returns

A valid outcome with no violations or prerequisites.

Source

pub fn invalid( violations: Vec<Violation>, ) -> Result<Self, ValidationOutcomeError>

Creates an invalid outcome with one or more violations.

§Parameters
  • violations: Non-empty safe violations produced by the validator.
§Returns

An invalid outcome containing violations.

§Errors

Returns ValidationOutcomeError::EmptyViolations when violations is empty.

Source

pub fn missing_optional() -> Self

Creates an outcome skipped because the optional target is absent.

§Returns

A skipped outcome with reason MissingOptional and no prerequisites.

Source

pub fn failed_prerequisite( prerequisites: Vec<FailureId>, ) -> Result<Self, ValidationOutcomeError>

Creates an outcome skipped after at least one prerequisite failed.

Every ID must refer to a failure already retained in the report that records this outcome.

§Parameters
  • prerequisites: Non-empty IDs of failures retained in the report.
§Returns

A skipped outcome with reason FailedPrerequisite and the supplied IDs.

§Errors

Returns ValidationOutcomeError::EmptyPrerequisites when prerequisites is empty.

Trait Implementations§

Source§

impl Debug for ValidationOutcome

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ValidationOutcome

Source§

impl PartialEq for ValidationOutcome

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ValidationOutcome

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.