Skip to content

Instantly share code, notes, and snippets.

@thrawn01
Last active October 20, 2016 14:43
Show Gist options
  • Save thrawn01/b8cffd15116dfa8667cc40dc6f966695 to your computer and use it in GitHub Desktop.
Save thrawn01/b8cffd15116dfa8667cc40dc6f966695 to your computer and use it in GitHub Desktop.
// I would like to see somthing like this
limit, err := validate.Int(r, "limit").Max(1000).Min(0).Default(1000).Value()
if err != nil {
return nil, err
}
// Over this
limit, err := scroll.GetIntField(r, "limit")
if err != nil {
if (err != scroll.MissingFieldError{"limit"}) {
return nil, scroll.GenericAPIError{Reason: "'limit' parameter is not an integer"}
}
limit = 1000
}
if limit < 0 || limit > 1000 {
limit = 1000
}
// Thoughts?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment