-
Notifications
You must be signed in to change notification settings - Fork 12
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
Possible bug #20
Comments
so in your example, a list value would be optional but an integer value would be required? |
@estebistec yeah well thats not clear from my example. here is a serializer: class MySerializer(Serializer):
authors = ListOrItemField(
PrimaryKeyRelatedField(
queryset=Authors.objects.all(),
error_messages={
'does_not_exist': _(u"Invalid Account: %s")
},
),
write_only=True,
required=False,
blank=True
) So, since {
"authors": ['Field `authors` is required', ]
} This is happening because undelying ListField did not receive _args and *_kwargs that were defined for original
def validate(self, value):
if value in validators.EMPTY_VALUES and self.required:
raise ValidationError(self.error_messages['required']) And this problem exists just for ListOrItemField, since ListField normally constructs field using _args and *_kwargs passed from serializer. |
Okay, I see. I'll poke at a fix this evening. Thanks for reporting it! |
Sorry, i haven't forgotten this. Simply passing args and kwargs didn't fix this like I'd hoped, so I have to dig deeper. |
Hm, that worked for me just fine. So passing empty list as value to a ListOrItemField did not result in |
@pySilver have you moved to DRF 3.0 yet? I'm thinking of upgrading this lib for it and if you're game I would ensure this bug is fixed or not present in that upgrade. |
@estebistec nop, our app is too big to make an easy upgrade to 3.0 :/ |
Please see #27 |
Hi!
Here is a possible bug:
https://github.com/estebistec/drf-compound-fields/blob/master/drf_compound_fields/fields.py#L105
Shouldn't it be(?):
Otherwise validators may report required field error for some circumstances. Consider example:
so, it woud result into:
[] -> Error
myfield
is requiredThe text was updated successfully, but these errors were encountered: