qubit_mixin/validatable.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! Traits for validation functionality
11//!
12
13/// A trait indicating that an entity class can be validated
14///
15/// This trait is used for validating the data of objects.
16///
17pub trait Validatable {
18 /// Validation error type
19 type Error;
20
21 /// Validates whether the data of this entity is valid
22 ///
23 /// # Returns
24 ///
25 /// `Ok(())` if the data is valid; otherwise returns `Err` containing
26 /// the validation error
27 fn validate(&self) -> Result<(), Self::Error>;
28}