Adds Docs to Const Type

This commit is contained in:
2025-06-23 15:30:07 -03:00
parent 198ebecef0
commit 60ac12fe39
2 changed files with 42 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
Const Type
=================
The const type is a special data type that allows a variable to be a single, fixed value.
It does not have the same properties as the other generic types, but it has the following specific properties:
- const: The fixed value that the variable must always hold.
- description: Description of the const field.
Examples
-----------------
.. code-block:: python
from jambo import SchemaConverter
schema = {
"title": "Country",
"type": "object",
"properties": {
"name": {
"const": "United States of America",
}
},
"required": ["name"],
}
Model = SchemaConverter.build(schema)
obj = Model()
self.assertEqual(obj.name, "United States of America")
with self.assertRaises(ValueError):
obj.name = "Canada"
with self.assertRaises(ValueError):
Model(name="Canada")

View File

@@ -45,4 +45,5 @@ For more complex schemas and types see our documentation on
usage.reference usage.reference
usage.allof usage.allof
usage.anyof usage.anyof
usage.enum usage.enum
usage.const