// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: bond.biblio.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. pub mod book; pub mod list; pub mod stamp; use jacquard_common::CowStr; #[allow(unused_imports)] use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; use jacquard_derive::{IntoStatic, lexicon}; use jacquard_lexicon::lexicon::LexiconDoc; use jacquard_lexicon::schema::LexiconSchema; #[allow(unused_imports)] use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; use serde::{Serialize, Deserialize}; /// A required book for a reading list, specified by title and authors for fuzzy matching #[lexicon] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde(rename_all = "camelCase")] pub struct BookRequirement<'a> { ///Author name(s), tab-separated for multiple #[serde(borrow)] pub authors: CowStr<'a>, #[serde(borrow)] pub title: CowStr<'a>, } impl<'a> LexiconSchema for BookRequirement<'a> { fn nsid() -> &'static str { "bond.biblio.defs" } fn def_name() -> &'static str { "bookRequirement" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_bond_biblio_defs() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.authors; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 500usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("authors"), max: 500usize, actual: ::len(value.as_ref()), }); } } { let value = &self.authors; { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 200usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("authors"), max: 200usize, actual: count, }); } } } { let value = &self.title; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 500usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("title"), max: 500usize, actual: ::len(value.as_ref()), }); } } { let value = &self.title; { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 200usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("title"), max: 200usize, actual: count, }); } } } Ok(()) } } fn lexicon_doc_bond_biblio_defs() -> LexiconDoc<'static> { #[allow(unused_imports)] use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; use jacquard_lexicon::lexicon::*; use alloc::collections::BTreeMap; LexiconDoc { lexicon: Lexicon::Lexicon1, id: CowStr::new_static("bond.biblio.defs"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("bookRequirement"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A required book for a reading list, specified by title and authors for fuzzy matching", ), ), required: Some( vec![ SmolStr::new_static("title"), SmolStr::new_static("authors") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("authors"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "Author name(s), tab-separated for multiple", ), ), max_length: Some(500usize), max_graphemes: Some(200usize), ..Default::default() }), ); map.insert( SmolStr::new_static("title"), LexObjectProperty::String(LexString { max_length: Some(500usize), max_graphemes: Some(200usize), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } }