use backbone_core::{EntityValidator, ValidationErrors, ValidationError};
use backbone_core::{OptionalNotBlank, RequiredString};
use crate::domain::entity::AttributeValue;
pub type AttributeValueValidator = EntityValidator<AttributeValue>;
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()))
}