backbone-bucket 0.4.6

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! Validator for ContentHash entity
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Returns an `EntityValidator<ContentHash>` 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::ContentHash;

/// Validator type alias for ContentHash entities.
pub type ContentHashValidator = EntityValidator<ContentHash>;

/// Build a validator for ContentHash with all schema-defined field rules.
pub fn content_hash_validator() -> ContentHashValidator {
    EntityValidator::new()
        .rule(RequiredString::new("hash", |e: &ContentHash| &e.hash))
        .rule(RequiredString::new("storage_key", |e: &ContentHash| &e.storage_key))
        .rule(NonNegative::new("reference_count", |e: &ContentHash| e.reference_count as i64))
        .rule(OptionalNotBlank::new("fingerprint", |e: &ContentHash| e.fingerprint.as_deref()))
}