https://github.com/emaddeve20/yaml-syntax
Make your own syntax or format to write a Yaml
https://github.com/emaddeve20/yaml-syntax
pydantic python python3 pyyaml yaml yaml-parser yaml-validator yaml2json
Last synced: 27 days ago
JSON representation
Make your own syntax or format to write a Yaml
- Host: GitHub
- URL: https://github.com/emaddeve20/yaml-syntax
- Owner: EmadDeve20
- License: gpl-3.0
- Created: 2025-10-30T16:01:00.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2025-11-07T15:41:22.000Z (7 months ago)
- Last Synced: 2025-11-07T17:27:48.613Z (7 months ago)
- Topics: pydantic, python, python3, pyyaml, yaml, yaml-parser, yaml-validator, yaml2json
- Language: Python
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yaml Syntax
yaml-syntax to check a YAML file with your own standard for keys or fields.
like you want a YAML file with these keys:
```version, service, name```
for this you can make a serializer with pydantic to check it:
```python
from pydantic import BaseModel
class MySyntax(BaseModel):
version:str
service:str
name:str
```
*Note*: You can use any option of BaseModel to build your own serializer. For example, use `Field` to create default values for your fields, or use `typing` to handle required fields, or anything else to make it more advanced.
and for example this is your yaml file:
```yaml
version: 'v1.0.0'
service: 'aws'
name: 'test'
```
then you can check this file is correct or not:
```python
from yaml_syntax.syntax import YamlSyntax
yaml = YamlSyntax.from_file(syntax_schema=MySyntax, yaml_file="test.yaml")
```
now you can use your serialized data:
```python
serialized_data = yaml.serialized_data
print(serialized_data.version)
```