# -*- coding: utf-8 -*- from __future__ import unicode_literals from tastypie.validation import Validation class UserValidation(Validation): ''' ''' def is_valid(self, bundle, request=None): if not bundle.data: return { '__all__': 'data not provided in bundle' } errors = {} if not 'first_name' in bundle.data: errors['first_name'] = 'this field is required' if not 'last_name' in bundle.data: errors['last_name'] = 'this field is required' if not 'username' in bundle.data: errors['username'] = 'this field is required' if not 'email' in bundle.data: errors['email'] = 'this field is required' if not 'password' in bundle.data: errors['password'] = 'this field is required' return errors