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§
Sourcefn validate_with_ctx(&self, ctx: &mut ValidationCtx) -> ValidationResult
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§
Sourcefn validate_all(&self) -> Result<(), ValidationErrors>
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.
Sourcefn validate(&self) -> Result<(), ValidationErrors>
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.
Sourcefn is_valid(&self) -> bool
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.
Sourcefn validated(self) -> Result<Self, ValidationErrors>
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§
impl ValidatedMessage for ()
impl ValidatedMessage for Color
common-types only.impl ValidatedMessage for Date
common-types only.impl ValidatedMessage for DateTime
common-types only.impl ValidatedMessage for Decimal
common-types only.impl ValidatedMessage for Expr
common-types only.impl ValidatedMessage for Fraction
common-types only.impl ValidatedMessage for Interval
common-types only.impl ValidatedMessage for LatLng
common-types only.impl ValidatedMessage for LocalizedText
common-types only.impl ValidatedMessage for Money
common-types only.impl ValidatedMessage for PhoneNumber
common-types only.impl ValidatedMessage for PostalAddress
common-types only.impl ValidatedMessage for Quaternion
common-types only.impl ValidatedMessage for TimeOfDay
common-types only.impl ValidatedMessage for TimeZone
common-types only.impl ValidatedMessage for Empty
impl ValidatedMessage for FieldViolation
rpc-types only.impl ValidatedMessage for Link
rpc-types only.impl ValidatedMessage for Violation
rpc-types only.impl ValidatedMessage for Violation
rpc-types only.impl ValidatedMessage for BadRequest
rpc-types only.impl ValidatedMessage for DebugInfo
rpc-types only.impl ValidatedMessage for ErrorInfo
rpc-types only.impl ValidatedMessage for Help
rpc-types only.impl ValidatedMessage for HttpHeader
rpc-types only.impl ValidatedMessage for HttpRequest
rpc-types only.impl ValidatedMessage for HttpResponse
rpc-types only.impl ValidatedMessage for LocalizedMessage
rpc-types only.impl ValidatedMessage for PreconditionFailure
rpc-types only.impl ValidatedMessage for QuotaFailure
rpc-types only.impl ValidatedMessage for RequestInfo
rpc-types only.impl ValidatedMessage for ResourceInfo
rpc-types only.impl ValidatedMessage for RetryInfo
rpc-types only.