Adds Docs for AllOf and AnyOf

This commit is contained in:
2025-06-21 18:20:44 -03:00
parent dee8b02d26
commit ac239c2617
4 changed files with 95 additions and 9 deletions

View File

@@ -0,0 +1,39 @@
AllOf Type
=================
The AllOf type is used to combine multiple schemas into a single schema. It allows you to specify that an object must conform to all of the specified schemas.
Examples
-----------------
.. code-block:: python
from jambo import SchemaConverter
schema = {
"title": "Person",
"description": "A person",
"type": "object",
"properties": {
"name": {
"allOf": [
{"type": "string", "maxLength": 11},
{"type": "string", "maxLength": 4},
{"type": "string", "minLength": 1},
{"type": "string", "minLength": 2},
]
},
},
}
Model = SchemaConverter.build(schema)
obj = Model(name="J")
print(obj) # Output: Person(name='J')
try:
obj = Model(name="") # This will raise a validation error
except ValueError as e:
print("Validation fails as expected:", e) # Output: Validation fails as expected: 1 validation error for Person