-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Pydantic Models for Validation #165
Support Pydantic Models for Validation #165
Conversation
…ories. Will work on implementing pulling from other Python packages.
…to consume models.
Co-authored-by: Christian Adell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion looks reasonable to me. I would defer to @glennmatthews to add his review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on a quick review it looks reasonable to me.
@@ -97,7 +97,24 @@ def top_level_properties(self): | |||
""" | |||
if not self._top_level_properties: | |||
content = self._get_content() | |||
self._top_level_properties = set(content.keys()) | |||
# TODO: Investigate and see if we should be checking this on initialization if the file doesn't exists or is empty. | |||
if not content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be something like if content is None
? Or is it intentional that if content
is an empty dict, empty str, or empty list then _top_level_properties
is unchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intentional. We can exit early if there is not content aka no data in the variable it found.
I was thinking we should handle this in the find_files
function. If the variable file is empty, no reason to worry about the file any longer (it won't have top level properties since it doesn't have content).
tests/fixtures/test_validators_pydantic/inventory/host_vars/az_phx_pe01/dns.yml
Show resolved
Hide resolved
tests/fixtures/test_validators_pydantic/inventory/host_vars/co_den_p01/dns.yml
Show resolved
Hide resolved
tests/fixtures/test_validators_pydantic/pydantic_validators/models/interfaces.py
Outdated
Show resolved
Hide resolved
…dPacket/schema-enforcer into feat/pydantic-model-validation
…en encountering invalid package/module when loading Pydantic models from an external package. Minor changes to address feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looks solid. Thanks for the updates!
PydanticManager
for loading Pydantic models from libraries.PydanticValidation
to run the specific Pydantic model validation against data.validator_directory
as well.[ERROR]
line.