Skip to content

Commit

Permalink
If there is no valid value in list fields, return empty list 🍺
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibyx committed Jan 1, 2020
1 parent 3318c84 commit afb78fc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.5.6 : 01.01.2020

- **Fix**: Fixing issue from version `0.5.5` but this time for real
- **Change**: Renamed version file from `__version__.py` to `version.py`

## 0.5.5 : 01.01.2020

- **Fix**: Check instance only if there is a value in `FieldList` and `FormFieldList`
Expand Down
1 change: 0 additions & 1 deletion django_request_formatter/__version__.py

This file was deleted.

10 changes: 8 additions & 2 deletions django_request_formatter/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def __init__(self, field, **kwargs):
super().__init__(**kwargs)

def to_python(self, value) -> typing.List:
if value and not isinstance(value, list):
if not value:
return []

if not isinstance(value, list):
raise ValidationError(self.error_messages['not_list'], code='not_list')

result = []
Expand Down Expand Up @@ -74,7 +77,10 @@ class FormFieldList(FormField):
}

def to_python(self, value):
if value and not isinstance(value, list):
if not value:
return []

if not isinstance(value, list):
raise ValidationError(self.error_messages['not_list'], code='not_list')

result = []
Expand Down
1 change: 1 addition & 0 deletions django_request_formatter/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.5.6'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def read_files(files):


meta = {}
with open('./django_request_formatter/__version__.py') as f:
with open('./django_request_formatter/version.py') as f:
exec(f.read(), meta)

setup(
Expand Down

0 comments on commit afb78fc

Please sign in to comment.