==================
Inspired by [Voluptuous](https://github.com/alecthomas/voluptuous).
It's sometimes inconvenient to define
named [Schematics](https://github.com/schematics/schematics)
Models, especially when those models are deeply nested.
Example:
```
class InnerModel(Model):
inner_bool = BooleanType()
class MiddleModel(Model):
middle_int = IntType()
middle_nested = ModelType(InnerModel)
class OuterModel(Model):
outer_str = StringType()
outer_nested = ModelType(MiddleModel)
model_instance = OuterModel(input_)
model_instance.validate()
```
So, this library provides a convenient syntax for defining
deeply nested Models.
```
from schematics_factory import model
OuterModel = model({
'outer_str': StringType(),
'outer_nested': ModelType(model({
'middle_int': IntType(),
'middle_nested': ModelType(model({
'inner_bool': BooleanType()
}))
}))
})
model_instance = OuterModel(input_)
model_instance.validate()
```
The model() function can also be imported as _model_factory_.
Alternative Syntax
------------------
Schema factory arguments can also be supplied as keyword
arguments rather than a dictionary.
```
Person = model(name=StringType(), age=IntType())
person = Person(dict(name='Test', age=27))
person.validate()
```
For nested Models, a concise __nested()__ convenience function
is provided to replace ModelType(model(...)) with nested(...).
The nested() function can also be imported as _nested_model_.
```
from schematics_factory import model, nested
Person = model(name=StringType(), pet=nested(name=StringType()))
person = Person(dict(name='Test', pet=dict(name='Rover')))
person.validate()
```
Nested models can also be provided as plain dictionary literals.
```
Person = model(name=StringType(), pet=dict(name=StringType()))
person = Person(dict(name='Test', pet=dict(name='Rover')))
person.validate()
```
Or equivalently...
```
Person = model({
'name': StringType(),
'pet': {
'name': StringType()
}
})
person = Person({
'name': 'Test',
'pet': {
'name': 'Rover'
}
})
person.validate()
```
Metadata
Release files for schematics-factory 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schematics-factory-0.1.0.tar.gz | 2.9 kB | Without provenance | Details for schematics-factory-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schematics_factory-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for schematics_factory-0.1.0-py2.py3-none-any.whl |
Total release size: 7.1 kB
Release files / schematics-factory-0.1.0.tar.gz
| Download URL | schematics-factory-0.1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b6e65e26ce44590fbd1235a45a43206b380c66e70eb05a0a4b7e4f1df4c4a59
|
|
BLAKE2b-256 checksum How to use checksums |
e72fb1b3d59ef04399e708f5ddfd3f0d1e0592bf25ef01139da01af886d1a7a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / schematics_factory-0.1.0-py2.py3-none-any.whl
| Download URL | schematics_factory-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a71d655965c1539ea180ae2b2556b9838301878b76282848c7d4c3f9d3833416
|
|
BLAKE2b-256 checksum How to use checksums |
3ebe39fac2919068c2b7f22a09601846c0c4a60bdbb1d69c4e7c706441227730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for schematics-factory 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.