// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: org.passingreads.book.registration
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::bytes::Bytes;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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};
use crate::org_passingreads::AspectRatio;
/// A book that has been registered on PassingReads

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "org.passingreads.book.registration",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Registration<S: BosStr = DefaultStr> {
    ///Aspect ratio of the cover image
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aspect_ratio: Option<AspectRatio<S>>,
    ///Authors of this book, in order of credit. An empty array implies a book of anonymous or unknown authorship.
    pub authors: Vec<S>,
    ///The book's ID (as defined on its QR Code)
    pub book_id: S,
    ///The MultiFormat public key of the book.
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub book_pub: Bytes,
    ///The MultiFormat signature of this record, without this attribute, as created by the private key associated with the book.
    #[serde(with = "jacquard_common::serde_bytes_helper")]
    pub book_sig: Bytes,
    ///Cover image of the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<BlobRef<S>>,
    ///The DID of the person who registered the book. Included here, so it's verifiable with the bookSig.
    pub did: Did<S>,
    pub occurred_at: Datetime,
    ///The book's Open Library Edition ID
    pub publication_id: S,
    ///The title of the book
    pub title: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RegistrationGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Registration<S>,
}

impl<S: BosStr> Registration<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, RegistrationRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct RegistrationRecord;
impl XrpcResp for RegistrationRecord {
    const NSID: &'static str = "org.passingreads.book.registration";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = RegistrationGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<RegistrationGetRecordOutput<S>> for Registration<S> {
    fn from(output: RegistrationGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Registration<S> {
    const NSID: &'static str = "org.passingreads.book.registration";
    type Record = RegistrationRecord;
}

impl Collection for RegistrationRecord {
    const NSID: &'static str = "org.passingreads.book.registration";
    type Record = RegistrationRecord;
}

impl<S: BosStr> LexiconSchema for Registration<S> {
    fn nsid() -> &'static str {
        "org.passingreads.book.registration"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_passingreads_book_registration()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.cover {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("cover"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.cover {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("cover"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("title"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod registration_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Authors;
        type BookId;
        type BookPub;
        type BookSig;
        type Did;
        type OccurredAt;
        type PublicationId;
        type Title;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Authors = Unset;
        type BookId = Unset;
        type BookPub = Unset;
        type BookSig = Unset;
        type Did = Unset;
        type OccurredAt = Unset;
        type PublicationId = Unset;
        type Title = Unset;
    }
    ///State transition - sets the `authors` field to Set
    pub struct SetAuthors<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthors<St> {}
    impl<St: State> State for SetAuthors<St> {
        type Authors = Set<members::authors>;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `book_id` field to Set
    pub struct SetBookId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBookId<St> {}
    impl<St: State> State for SetBookId<St> {
        type Authors = St::Authors;
        type BookId = Set<members::book_id>;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `book_pub` field to Set
    pub struct SetBookPub<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBookPub<St> {}
    impl<St: State> State for SetBookPub<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = Set<members::book_pub>;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `book_sig` field to Set
    pub struct SetBookSig<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBookSig<St> {}
    impl<St: State> State for SetBookSig<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = Set<members::book_sig>;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = Set<members::did>;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `occurred_at` field to Set
    pub struct SetOccurredAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOccurredAt<St> {}
    impl<St: State> State for SetOccurredAt<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = Set<members::occurred_at>;
        type PublicationId = St::PublicationId;
        type Title = St::Title;
    }
    ///State transition - sets the `publication_id` field to Set
    pub struct SetPublicationId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPublicationId<St> {}
    impl<St: State> State for SetPublicationId<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = Set<members::publication_id>;
        type Title = St::Title;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTitle<St> {}
    impl<St: State> State for SetTitle<St> {
        type Authors = St::Authors;
        type BookId = St::BookId;
        type BookPub = St::BookPub;
        type BookSig = St::BookSig;
        type Did = St::Did;
        type OccurredAt = St::OccurredAt;
        type PublicationId = St::PublicationId;
        type Title = Set<members::title>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `authors` field
        pub struct authors(());
        ///Marker type for the `book_id` field
        pub struct book_id(());
        ///Marker type for the `book_pub` field
        pub struct book_pub(());
        ///Marker type for the `book_sig` field
        pub struct book_sig(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `occurred_at` field
        pub struct occurred_at(());
        ///Marker type for the `publication_id` field
        pub struct publication_id(());
        ///Marker type for the `title` field
        pub struct title(());
    }
}

/// Builder for constructing an instance of this type.
pub struct RegistrationBuilder<St: registration_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<AspectRatio<S>>,
        Option<Vec<S>>,
        Option<S>,
        Option<Bytes>,
        Option<Bytes>,
        Option<BlobRef<S>>,
        Option<Did<S>>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Registration<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> RegistrationBuilder<registration_state::Empty, DefaultStr> {
        RegistrationBuilder::new()
    }
}

impl<S: BosStr> Registration<S> {
    /// Create a new builder for this type
    pub fn builder() -> RegistrationBuilder<registration_state::Empty, S> {
        RegistrationBuilder::builder()
    }
}

impl RegistrationBuilder<registration_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        RegistrationBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> RegistrationBuilder<registration_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        RegistrationBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St: registration_state::State, S: BosStr> RegistrationBuilder<St, S> {
    /// Set the `aspectRatio` field (optional)
    pub fn aspect_ratio(mut self, value: impl Into<Option<AspectRatio<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `aspectRatio` field to an Option value (optional)
    pub fn maybe_aspect_ratio(mut self, value: Option<AspectRatio<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::Authors: registration_state::IsUnset,
{
    /// Set the `authors` field (required)
    pub fn authors(
        mut self,
        value: impl Into<Vec<S>>,
    ) -> RegistrationBuilder<registration_state::SetAuthors<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::BookId: registration_state::IsUnset,
{
    /// Set the `bookId` field (required)
    pub fn book_id(
        mut self,
        value: impl Into<S>,
    ) -> RegistrationBuilder<registration_state::SetBookId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::BookPub: registration_state::IsUnset,
{
    /// Set the `bookPub` field (required)
    pub fn book_pub(
        mut self,
        value: impl Into<Bytes>,
    ) -> RegistrationBuilder<registration_state::SetBookPub<St>, S> {
        self._fields.3 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::BookSig: registration_state::IsUnset,
{
    /// Set the `bookSig` field (required)
    pub fn book_sig(
        mut self,
        value: impl Into<Bytes>,
    ) -> RegistrationBuilder<registration_state::SetBookSig<St>, S> {
        self._fields.4 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: registration_state::State, S: BosStr> RegistrationBuilder<St, S> {
    /// Set the `cover` field (optional)
    pub fn cover(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `cover` field to an Option value (optional)
    pub fn maybe_cover(mut self, value: Option<BlobRef<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::Did: registration_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> RegistrationBuilder<registration_state::SetDid<St>, S> {
        self._fields.6 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::OccurredAt: registration_state::IsUnset,
{
    /// Set the `occurredAt` field (required)
    pub fn occurred_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> RegistrationBuilder<registration_state::SetOccurredAt<St>, S> {
        self._fields.7 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::PublicationId: registration_state::IsUnset,
{
    /// Set the `publicationId` field (required)
    pub fn publication_id(
        mut self,
        value: impl Into<S>,
    ) -> RegistrationBuilder<registration_state::SetPublicationId<St>, S> {
        self._fields.8 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::Title: registration_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<S>,
    ) -> RegistrationBuilder<registration_state::SetTitle<St>, S> {
        self._fields.9 = Option::Some(value.into());
        RegistrationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RegistrationBuilder<St, S>
where
    St: registration_state::State,
    St::Authors: registration_state::IsSet,
    St::BookId: registration_state::IsSet,
    St::BookPub: registration_state::IsSet,
    St::BookSig: registration_state::IsSet,
    St::Did: registration_state::IsSet,
    St::OccurredAt: registration_state::IsSet,
    St::PublicationId: registration_state::IsSet,
    St::Title: registration_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Registration<S> {
        Registration {
            aspect_ratio: self._fields.0,
            authors: self._fields.1.unwrap(),
            book_id: self._fields.2.unwrap(),
            book_pub: self._fields.3.unwrap(),
            book_sig: self._fields.4.unwrap(),
            cover: self._fields.5,
            did: self._fields.6.unwrap(),
            occurred_at: self._fields.7.unwrap(),
            publication_id: self._fields.8.unwrap(),
            title: self._fields.9.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Registration<S> {
        Registration {
            aspect_ratio: self._fields.0,
            authors: self._fields.1.unwrap(),
            book_id: self._fields.2.unwrap(),
            book_pub: self._fields.3.unwrap(),
            book_sig: self._fields.4.unwrap(),
            cover: self._fields.5,
            did: self._fields.6.unwrap(),
            occurred_at: self._fields.7.unwrap(),
            publication_id: self._fields.8.unwrap(),
            title: self._fields.9.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_passingreads_book_registration() -> 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("org.passingreads.book.registration"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A book that has been registered on PassingReads",
                        ),
                    ),
                    key: Some(CowStr::new_static("any")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("did"), SmolStr::new_static("bookId"),
                                SmolStr::new_static("title"),
                                SmolStr::new_static("authors"),
                                SmolStr::new_static("publicationId"),
                                SmolStr::new_static("occurredAt"),
                                SmolStr::new_static("bookPub"),
                                SmolStr::new_static("bookSig")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("aspectRatio"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "org.passingreads.defs#aspectRatio",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("authors"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Authors of this book, in order of credit. An empty array implies a book of anonymous or unknown authorship.",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        min_length: Some(1usize),
                                        max_length: Some(512usize),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("bookId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The book's ID (as defined on its QR Code)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("bookPub"),
                                LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("bookSig"),
                                LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("cover"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("did"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The DID of the person who registered the book. Included here, so it's verifiable with the bookSig.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurredAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("publicationId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The book's Open Library Edition ID"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The title of the book"),
                                    ),
                                    min_length: Some(1usize),
                                    max_length: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}