feat(project): add pydantic validator for common_id field#5974
feat(project): add pydantic validator for common_id field#5974soumyaDghosh wants to merge 1 commit intocanonical:mainfrom
Conversation
Signed-off-by: Soumyadeep Ghosh <soumyadeepghosh2004@zohomail.in>
mr-cal
left a comment
There was a problem hiding this comment.
This will be a great improvement, thanks @soumyaDghosh!
Currently, neither snap pack nor review-tools.snap-review catch invalid common-ids, right? (I'm testing locally and can't get either to raise an error). The reason I'm asking is that I'm considering putting this in Snapcraft 9 instead of 8.15.
|
|
||
| See :ref:`how-to-configure-package-information` for details. | ||
| The common-id must be in reverse DNS format and consist only of alphanumeric characters and the | ||
| following special characters: ``., _, -``. |
There was a problem hiding this comment.
| following special characters: ``., _, -``. | |
| following special characters: ``.``, ``_``, ``-``. |
|
|
||
| def test_app_common_id(self, app_yaml_data): | ||
| data = app_yaml_data(common_id="test-common-id") | ||
| def test_app_valid_common_id(self, app_yaml_data): |
There was a problem hiding this comment.
To exercise the regex, can you do a pytest.mark.parameterize for this test and the next test to test a few valid and invalid common ids?
And can you add id's for the invalid ones to explain them? (for example, @pytest.param("te$t", id="invalid-character"))
| ) | ||
| return extensions | ||
|
|
||
| @pydantic.field_validator("common_id") |
There was a problem hiding this comment.
@lengau, please correct me here, but I believe the preferred way to add new regex validation is like this:
fixes #5624
make lint && make test.