Skip to content

Commit

Permalink
feat(validation): Add word count to description error.
Browse files Browse the repository at this point in the history
Closes #422
  • Loading branch information
vchendrix committed Jan 25, 2024
1 parent 7a1ebc4 commit c749193
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion archive_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def validate(self, data):

# Make sure description has at least 100 words
if 'description' in data.keys() and data['description'] and len(data['description'].split()) < 100:
errors["description"] = "Description must be at least 100 words."
errors["description"] = f"Description must be at least 100 words. Current count is {len(data['description'].split())}."

# Validate the selected plots
if 'plots' in data.keys():
Expand Down
4 changes: 2 additions & 2 deletions archive_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def test_user_workflow(self):
value = json.loads(response.content.decode('utf-8'))
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
self.assertEqual(
{'description': ['Description must be at least 100 words.'],
{'description': ['Description must be at least 100 words. Current count is 37.'],
'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution',
'qaqc_method_description']},
value)
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_admin_approve_workflow(self):
response = self.client.get("/api/v1/datasets/1/submit/") # In draft mode, owned by auser
value = json.loads(response.content.decode('utf-8'))
self.assertEqual(
{'description': ['Description must be at least 100 words.'],
{'description': ['Description must be at least 100 words. Current count is 37.'],
'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution',
'qaqc_method_description']},
value)
Expand Down

0 comments on commit c749193

Please sign in to comment.