Story #5927
As a plugin writer, I have docs recommending I use Serializers to validate any model data
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
Associated revisions
History
#1
Updated by daviddavis about 1 year ago
- Description updated (diff)
#2
Updated by bmbouter about 1 year ago
- Groomed changed from No to Yes
- Sprint Candidate changed from No to Yes
#3
Updated by rchan about 1 year ago
- Sprint set to Sprint 64
#5
Updated by fao89 12 months 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
#12
Updated by daviddavis 11 months ago
- Sprint/Milestone changed from 3.1.0 to 3.2.0
#14
Updated by daviddavis 11 months ago
- Sprint/Milestone changed from 3.2.0 to 3.3.0
#16
Updated by fao89 10 months ago
- Blocks Task #5828: Document how to validate data in plugin writer guide added
#18
Updated by daviddavis 10 months ago
- Sprint/Milestone deleted (
3.3.0)
#33
Updated by mdellweg 5 months ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulpcore|1ccbdfe49fb7083907a3ce26e6e64822eb1097d8.
Please register to edit this issue
Add documentation for validating models
fixes #5927 https://pulp.plan.io/issues/5927