ValidationCheck

Trait ValidationCheck 

Source
pub trait ValidationCheck: Sized {
    // Required method
    fn validate_new(messages: ValidateErrorStore) -> Self;

    // Provided method
    fn validate_check(messages: ValidateErrorCollector) -> Result<(), Self> { ... }
}
Expand description

A trait for performing validation checks and handling validation-related errors.

This trait provides methods to:

  • Create a new validation error instance from an error store.
  • Collect and validate errors, returning a result depending on whether any errors are found.

§Associated Types

  • Self: The concrete type that implements the ValidationCheck trait, which represents validation errors.

§Required Methods

§validate_new

Creates a new instance of the implementing type using a provided ValidateErrorStore.

§Parameters

  • messages: An instance of ValidateErrorStore that holds validation error information.

§Returns

  • Self: A new instance of the implementing type initialized with the given error messages.

§Provided Methods

§validate_check

Performs a validation check using a ValidateErrorCollector. If the collector contains errors, it returns an error wrapped in the implementing type; otherwise, it succeeds with Ok(()).

§Parameters

  • messages: An instance of ValidateErrorCollector that holds collected validation errors.

§Returns

  • Ok(()): If the collector does not contain any errors.
  • Err(Self): If the collector contains errors, an error instance of the implementing type is returned.

The default implementation checks if the provided messages is empty. If it is empty, it returns an Ok(()). Otherwise, it converts the messages into a ValidateErrorStore and creates a new validation error instance using validate_new.

Required Methods§

Provided Methods§

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.

Implementors§

Source§

impl ValidationCheck for DescriptionError

Source§

impl ValidationCheck for EmailError

Available on crate feature email only.
Source§

impl ValidationCheck for NameError

Source§

impl ValidationCheck for FloatError

Source§

impl ValidationCheck for IntegerError

Source§

impl ValidationCheck for UnsignedError

Source§

impl ValidationCheck for PasswordError

Source§

impl ValidationCheck for DateError

Available on crate feature chrono only.
Source§

impl ValidationCheck for cjtoolkit_structured_validator::types::times_chrono::date_time::DateTimeError

Available on crate feature chrono only.
Source§

impl ValidationCheck for NaiveDateTimeError

Available on crate feature chrono only.
Source§

impl ValidationCheck for TimeError

Available on crate feature chrono only.
Source§

impl ValidationCheck for cjtoolkit_structured_validator::types::times_humantime::DateTimeError

Available on crate feature humantime only.
Source§

impl ValidationCheck for UrlError

Available on crate feature url only.
Source§

impl ValidationCheck for UsernameError