-
Notifications
You must be signed in to change notification settings - Fork 13
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
refactor: migrates rule validation to pydantic #207
Conversation
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.
Reviewed during paired code review today. Example of updated error messages attached.
@beatrizmcouto Rebased this branch after the merge of #195. PTAL at minor changes in 73a3ea2. |
Pydantic custom rule validation and error handling with some minor tweaks supports can accomplish what the goal was for the ValidationHandler class. Removing in favor of a more cohesive validation solution. Signed-off-by: Jennifer Power <[email protected]>
Signed-off-by: Jennifer Power <[email protected]>
To make the YAML test data more readable, define the alternative paramerer mappings in proper YAML. Signed-off-by: Jennifer Power <[email protected]>
The default key value can be set automatically during transformation to keep it from being defined twice in YAML. If defined twice, it will just be validated that it matches the default value string. Signed-off-by: Jennifer Power <[email protected]>
When the CLI errors, the error logs are not very clear and the error should multiple times. This will help make the error more readable. Signed-off-by: Jennifer Power <[email protected]>
Signed-off-by: Jennifer Power <[email protected]>
Signed-off-by: Jennifer Power <[email protected]>
Signed-off-by: Jennifer Power <[email protected]>
For validation with pydantic per YAML file, we want to collect all of the validation errors up front and give a consistent, detailed message for an efficient workflow. Signed-off-by: Jennifer Power <[email protected]>
The path contains the component information making the file easier to indentify for fixing errors. Signed-off-by: Jennifer Power <[email protected]>
Renamed variable to be more descriptive and removes extra call to errors() method Signed-off-by: Jennifer Power <[email protected]>
8d53c30
to
73a3ea2
Compare
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.
Approved formatting of error message update and deduplication of a small part of the code
Description
Removes classes related to custom validation and uses pydantic for custom validation relating to the
TrestleRule
model.The output of validation failures were not clear so with this change, the clarity was improved.
Fixes #205
Rationale
Field validations should not be optional, but there may be a use-case where we need optional validation. This can be handled with the
trestle
Validator classes. Thus, there should be no need for classes supporting validation in this project.Type of change
How has this been tested?
Checklist