Skip to main content

ValidatedMessage

Trait ValidatedMessage 

Source
pub trait ValidatedMessage:
    ProtoValidation
    + Default
    + Clone {
    // Required method
    fn validate_with_ctx(&self, ctx: &mut ValidationCtx) -> ValidationResult;

    // Provided methods
    fn validate_all(&self) -> Result<(), ValidationErrors> { ... }
    fn validate(&self) -> Result<(), ValidationErrors> { ... }
    fn is_valid(&self) -> bool { ... }
    fn validated(self) -> Result<Self, ValidationErrors> { ... }
}
Expand description

Trait that executes validation on a message, if the latter had validators assigned to it via the attributes in proto_message.

Required Methods§

Source

fn validate_with_ctx(&self, ctx: &mut ValidationCtx) -> ValidationResult

Executes validation on this message, triggering the validators that have been assigned to it via macro attributes, if there are any.

Provided Methods§

Source

fn validate_all(&self) -> Result<(), ValidationErrors>

Executes validation on this message, triggering the validators that have been assigned to it via macro attributes, if there are any.

Unlike the validate method, it sets fail_fast to false, so that validation will continue even if a violation has already been found.

Source

fn validate(&self) -> Result<(), ValidationErrors>

Executes validation on this message, triggering the validators that have been assigned to it via macro attributes, if there are any.

Uses the default values for ValidationCtx, including fail_fast: true.

Source

fn is_valid(&self) -> bool

Executes validation on this message, triggering the validators that have been assigned to it via macro attributes, and returns true if the validation was successful.

Uses the default values for ValidationCtx, including fail_fast: true.

Source

fn validated(self) -> Result<Self, ValidationErrors>

Executes validation on this message, triggering the validators that have been assigned to it via macro attributes, if there are any, and returns the value if validation was successful.

Uses the default values for ValidationCtx, including fail_fast: true.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ValidatedMessage for ()

Source§

impl ValidatedMessage for Color

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Date

Available on crate feature common-types only.
Source§

impl ValidatedMessage for DateTime

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Decimal

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Expr

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Fraction

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Interval

Available on crate feature common-types only.
Source§

impl ValidatedMessage for LatLng

Available on crate feature common-types only.
Source§

impl ValidatedMessage for LocalizedText

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Money

Available on crate feature common-types only.
Source§

impl ValidatedMessage for PhoneNumber

Available on crate feature common-types only.
Source§

impl ValidatedMessage for PostalAddress

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Quaternion

Available on crate feature common-types only.
Source§

impl ValidatedMessage for TimeOfDay

Available on crate feature common-types only.
Source§

impl ValidatedMessage for TimeZone

Available on crate feature common-types only.
Source§

impl ValidatedMessage for Empty

Source§

impl ValidatedMessage for FieldViolation

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for Violation

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for Violation

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for BadRequest

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for DebugInfo

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for ErrorInfo

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for Help

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for HttpHeader

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for HttpRequest

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for HttpResponse

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for LocalizedMessage

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for PreconditionFailure

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for QuotaFailure

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for RequestInfo

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for ResourceInfo

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for RetryInfo

Available on crate feature rpc-types only.
Source§

impl ValidatedMessage for Status

Implementors§