Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusfrdk committed Feb 5, 2025
1 parent 02eb548 commit 0a13283
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ from tomlval import TOMLValidator, TOMLSchema
path = pathlib.Path("data.toml")

with path.open("rb") as file:
data = tomllib.load(file)
data_file = tomllib.load(file)

# Use a dictionary
# data = {
# "first_name": "John",
# "last_name": "Doe",
# "age": 25,
# ...
# }
data_dict = {
"first_name": "John",
"last_name": "Doe",
"age": 25
}

# Define schema (optional)
structure = {
Expand Down Expand Up @@ -141,7 +140,8 @@ validator.add_handler("age", lambda value: None if 18 < value < 100 else "invali
validator.add_handler("*", lambda: "invalid-key")

# Validate the data
errors = validator.validate(data)
errors_file = validator.validate(data_file)
errors_dict = validator.validate(data_dict)
```

## Future Plans
Expand Down

0 comments on commit 0a13283

Please sign in to comment.