Skip to content
This repository has been archived by the owner on Nov 18, 2017. It is now read-only.

Validate against empty comments #58

Merged
merged 6 commits into from
Jun 11, 2014
Merged

Validate against empty comments #58

merged 6 commits into from
Jun 11, 2014

Conversation

pbrisbin
Copy link
Contributor

@pbrisbin pbrisbin commented Jun 6, 2014

  • Refactor comment creation and insertion to have a place for validations
  • Respond 400 with a body of {"errors":["Useful error","..."]} in invalid cases
  • Validate that comments aren't empty

I'm not sure yet if or how the client-side handles these errors.

@pbrisbin
Copy link
Contributor Author

Ping @jferris

sendResponseStatus status201 $ object
["comment" .= UserComment (Entity cid c) u]

updateComment :: CommentId -> Entity User -> CommentRequest -> Handler Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insertComment and updateComment are pretty similar. I'm guessing it would get kludgy if you tried to abstract over them, but it's something that jumped out at me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was what I found, the placement and relative ratio of the differences (time given to toComment, action given to runDB, and status given to sendResponseStatus) is such that, even though the functions have the same shape, any DRYing just decreases readability (IMO).

@pbrisbin pbrisbin merged commit 929973e into master Jun 11, 2014
@pbrisbin pbrisbin deleted the pb-validations branch June 11, 2014 14:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants