backbone-accounting 0.9.27

GL, journals, ledger, reconciliation (extracted from bersihir)
Documentation
//! Validator for CostCenter entity
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Returns an `EntityValidator<CostCenter>` pre-loaded with schema-derived
//! field rules. Extend in the `// <<< CUSTOM` zone.

use backbone_core::{EntityValidator, ValidationErrors, ValidationError};
use backbone_core::{NonNegative, OptionalNotBlank, RequiredString};
use crate::domain::entity::CostCenter;

/// Validator type alias for CostCenter entities.
pub type CostCenterValidator = EntityValidator<CostCenter>;

/// Build a validator for CostCenter with all schema-defined field rules.
pub fn cost_center_validator() -> CostCenterValidator {
    EntityValidator::new()
        .rule(RequiredString::new("code", |e: &CostCenter| &e.code))
        .rule(RequiredString::new("name", |e: &CostCenter| &e.name))
        .rule(OptionalNotBlank::new("description", |e: &CostCenter| e.description.as_deref()))
        .rule(NonNegative::new("level", |e: &CostCenter| e.level as i64))
    // <<< CUSTOM RULES
    // END CUSTOM RULES
}

// <<< CUSTOM
// END CUSTOM