backbone-catalog 0.7.0

Canonical product/service identity: Item, Item Group, UOM (Indonesia-first)
Documentation
//! Validator for AttributeValue entity
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Returns an `EntityValidator<AttributeValue>` pre-loaded with schema-derived
//! field rules. Extend in the `// <<< CUSTOM` zone.

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

/// Validator type alias for AttributeValue entities.
pub type AttributeValueValidator = EntityValidator<AttributeValue>;

/// Build a validator for AttributeValue with all schema-defined field rules.
pub fn attribute_value_validator() -> AttributeValueValidator {
    EntityValidator::new()
        .rule(RequiredString::new("code", |e: &AttributeValue| &e.code))
        .rule(RequiredString::new("label", |e: &AttributeValue| &e.label))
        .rule(OptionalNotBlank::new("label_en", |e: &AttributeValue| e.label_en.as_deref()))
        .rule(OptionalNotBlank::new("swatch_hex", |e: &AttributeValue| e.swatch_hex.as_deref()))
        .rule(OptionalNotBlank::new("icon", |e: &AttributeValue| e.icon.as_deref()))
    // <<< CUSTOM RULES
    // END CUSTOM RULES
}

// <<< CUSTOM
// END CUSTOM