https://github.com/jakeroggenbuck/typeschemalib
A yaml like schema that can be used to check dictionaries for correct schema
https://github.com/jakeroggenbuck/typeschemalib
pip schema yaml
Last synced: about 2 months ago
JSON representation
A yaml like schema that can be used to check dictionaries for correct schema
- Host: GitHub
- URL: https://github.com/jakeroggenbuck/typeschemalib
- Owner: JakeRoggenbuck
- License: mit
- Created: 2020-09-20T05:36:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-28T19:02:22.000Z (over 5 years ago)
- Last Synced: 2025-03-23T21:46:42.841Z (over 1 year ago)
- Topics: pip, schema, yaml
- Language: Python
- Homepage: https://pypi.org/project/typeschemalib/
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typeschemalib
A yaml-like schema that can be used to check dictionaries for correct schema. [Typelibschema](https://pypi.org/project/typeschemalib/) is published to Pypi.org.
## Install
```
pip install typeschemalib
```
## Schema file
#### schema example
```
point: Int
my_string: Str
grade: Float
```
#### data example
```json
{"point": 45, "my_string": "Hey", "grade": 4.5}
```
## Checking data for correct schema
### Test parse with stml file
```py
from typeschemalib import typeschemalib
if __name__ == "__main__":
data = {"point": 45, "my_string": "Hey", "grade": 4.5}
# Validate data from schema file
schema = "test.stml"
valid = typeschemalib.schema_check(schema, data)
print(valid)
# Validate data from list of schema
schema = ["point: Int", "my_string: Str", "grade: Int"]
valid = typeschemalib.schema_check(schema, data)
print(valid)
# Validate data from dict of values
schema = {"point": "Int", "my_string": "Str", "grade": "Int"}
valid = typeschemalib.schema_check(schema, data)
print(valid)
```
## Todo
- [ ] Make schema have regex
- [ ] Make documentation for stml writer
- [ ] Add object type and class checker, isinstance issubclass `time: DateTimeObject`