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
| Attribute | Type | Description |
|---|---|---|
| type | Literal['uuid'] | Fixed identifier indicating the schema represents a UUID type. |
| version | Literal[1, 3, 4, 5, 7] | The specific UUID version to validate against, restricted to versions 1, 3, 4, 5, or 7. |
| strict | bool | Determines whether to enforce strict validation rules during parsing. |
| ref | str | A reference string used for recursive schemas or internal identification. |
| metadata | dict[str, Any] | A dictionary of additional metadata used to store custom information about the schema. |
| serialization | SerSchema | Custom 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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
bool | A 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
| Type | Description |
|---|---|
str | The 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
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
SerSchema | The serialization schema configuration object |