Skip to main content

UuidSchema

This class defines a schema for UUID validation and serialization within a type-safe dictionary structure. It allows for specifying the UUID version, enforcing strict format checks, and attaching custom metadata or serialization rules.

Attributes

AttributeTypeDescription
typeLiteral['uuid']Fixed identifier indicating the schema represents a UUID type.
versionLiteral[1, 3, 4, 5, 7]The specific UUID version to validate against, restricted to versions 1, 3, 4, 5, or 7.
strictboolDetermines whether to enforce strict validation rules during parsing.
refstrA reference string used for recursive schemas or internal identification.
metadatadict[str, Any]A dictionary of additional metadata used to store custom information about the schema.
serializationSerSchemaCustom serialization configuration defining how the UUID should be converted to other formats.

Methods


type()

def type() - > Literal['uuid']

Specifies the schema type as a UUID. This field is required to identify the validation logic for UUID strings.

Returns

TypeDescription
Literal['uuid']The literal string 'uuid' identifying the schema type

version()

def version() - > Literal[1, 3, 4, 5, 7]

Defines the specific UUID version to validate against. Restricts acceptable input to the specified RFC 4122 or RFC 9562 version.

Returns

TypeDescription
Literal[1, 3, 4, 5, 7]The integer representing the allowed UUID version

strict()

def strict() - > bool

Determines whether the validation should enforce strict UUID formatting. When true, it ensures the input strictly adheres to standard UUID string representations.

Returns

TypeDescription
boolA boolean flag indicating if strict validation is enabled

ref()

def ref() - > str

Provides a reference identifier for the schema. Used for recursive schema definitions or internal referencing within a larger schema structure.

Returns

TypeDescription
strThe reference string identifier

metadata()

def metadata() - > dict[str, Any]

Stores an arbitrary dictionary of metadata associated with the schema. This is typically used for documentation generation or custom extensions.

Returns

TypeDescription
dict[str, Any]A dictionary containing custom metadata key-value pairs

serialization()

def serialization() - > SerSchema

Configures how the UUID should be handled during serialization processes. Defines the transformation logic when converting the UUID back to a serializable format.

Returns

TypeDescription
SerSchemaThe serialization schema configuration object