use backbone_core::{EntityValidator, ValidationErrors, ValidationError};
use backbone_core::{NonNegative, OptionalNotBlank, RequiredString};
use crate::domain::entity::StoredFile;
pub type StoredFileValidator = EntityValidator<StoredFile>;
pub fn stored_file_validator() -> StoredFileValidator {
EntityValidator::new()
.rule(RequiredString::new("path", |e: &StoredFile| &e.path))
.rule(RequiredString::new("original_name", |e: &StoredFile| &e.original_name))
.rule(NonNegative::new("size_bytes", |e: &StoredFile| e.size_bytes))
.rule(RequiredString::new("mime_type", |e: &StoredFile| &e.mime_type))
.rule(OptionalNotBlank::new("checksum", |e: &StoredFile| e.checksum.as_deref()))
.rule(OptionalNotBlank::new("compression_algorithm", |e: &StoredFile| e.compression_algorithm.as_deref()))
.rule(OptionalNotBlank::new("thumbnail_path", |e: &StoredFile| e.thumbnail_path.as_deref()))
.rule(OptionalNotBlank::new("cdn_url", |e: &StoredFile| e.cdn_url.as_deref()))
.rule(OptionalNotBlank::new("owner_module", |e: &StoredFile| e.owner_module.as_deref()))
.rule(OptionalNotBlank::new("owner_entity", |e: &StoredFile| e.owner_entity.as_deref()))
.rule(OptionalNotBlank::new("field_name", |e: &StoredFile| e.field_name.as_deref()))
.rule(RequiredString::new("storage_key", |e: &StoredFile| &e.storage_key))
.rule(NonNegative::new("download_count", |e: &StoredFile| e.download_count as i64))
}