Story #5927
closedAs a plugin writer, I have docs recommending I use Serializers to validate any model data
Added by daviddavis over 4 years ago. Updated almost 4 years ago.
100%
Description
In a discussion on pulp-dev we decided that models shouldn't validate data (but rather serializers should).
We should add a section to the plugin writers guide here called "Validating Models" which makes these recommendations.
Related issues
Updated by bmbouter over 4 years ago
- Groomed changed from No to Yes
- Sprint Candidate changed from No to Yes
Updated by fao89 over 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to fao89
Updated by fao89 over 4 years ago
I have an implementation, but I made so many workarounds:
https://github.com/pulp/pulpcore/pull/514
1 - I adapted PulpPluginAppConfig for getting the serializers (2 serializers with the same model, results in dict with only the last serializer)
2 - Convert model to dict for using it on serializer
2.1 - serializers with nested serializers like DistributionTreeSerializer: https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/serializers.py#L1020
I'm sending an empty list on the related fields like: "addons": [], "checksums": [], ...
2.2 - SingleArtifactContentUploadSerializer needs relative_path, artifact / file, I'm sending a fake file,
but when validation requires a specific kind of file it fails. I got it here: https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/serializers.py#L232-L246
which I treated by avoiding deferred_validate
but I also got a problem here:
https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/serializers.py#L500-L513
that I could not treat
Updated by fao89 over 4 years ago
- Status changed from ASSIGNED to POST
Updated by fao89 over 4 years ago
- Status changed from POST to NEW
- Assignee deleted (
fao89)
Updated by fao89 over 4 years ago
- Description updated (diff)
- Status changed from NEW to ASSIGNED
- Assignee set to fao89
Updated by fao89 over 4 years ago
- Status changed from ASSIGNED to POST
Updated by daviddavis over 4 years ago
- Sprint/Milestone changed from 3.1.0 to 3.2.0
Updated by daviddavis over 4 years ago
- Sprint/Milestone changed from 3.2.0 to 3.3.0
Updated by fao89 over 4 years ago
- Blocks Task #5828: Document how to validate data in plugin writer guide added
Updated by pulpbot over 4 years ago
Updated by bmbouter over 4 years ago
- Status changed from POST to NEW
Bringing back to new before I rewrite the issue to be only a docs change.
Updated by bmbouter over 4 years ago
- Subject changed from As a plugin writer, I can validate Content data in the Stages API to As a plugin writer, I have docs recommending I use Serializers to validate any model data
- Description updated (diff)
- Tags Documentation added
Updated by mdellweg about 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to mdellweg
Updated by pulpbot about 4 years ago
- Status changed from ASSIGNED to POST
Added by mdellweg almost 4 years ago
Updated by mdellweg almost 4 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulpcore|1ccbdfe49fb7083907a3ce26e6e64822eb1097d8.
Updated by pulpbot almost 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Add documentation for validating models
fixes #5927 https://pulp.plan.io/issues/5927