Skip to content

Instantly share code, notes, and snippets.

@grlindburg
Created February 1, 2015 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grlindburg/e5463b03a87b7e3a114b to your computer and use it in GitHub Desktop.
Save grlindburg/e5463b03a87b7e3a114b to your computer and use it in GitHub Desktop.
def create_post(request):
db = request.db
cache = request.cache
user = request.user
# Schema
schema = Schema({
Required('body'): All(Coerce(unicode),
Length(min=5, max=3000, msg='A post is between 5 and 3000 characters.'),
StripWhitespace,
RemoveMultipleNewlines),
Required('tag_categories'): All(Length(max=2),
[{Required('id'): Coerce(int)}]),
Optional('files', default=[]): [{Required('id'): Coerce(int)}],
Optional('mobile', default=False): Boolean()
})
payload = schema(request.json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment