Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error formating. #44

Merged
merged 6 commits into from
Jul 25, 2015
Merged

Added error formating. #44

merged 6 commits into from
Jul 25, 2015

Conversation

jerel
Copy link
Member

@jerel jerel commented Jul 24, 2015

By default validation errors will be formatted like so:

{
    errors: [{
        detail: 'First name is required',
        source: {
            pointer: '/data/attributes/first-name'
        },
        status: '400'
    }]
}

However if you want to throw a custom validation error you can pass a dictionary and it will be used:

def validate_first_name(self, data):
    raise ValidationError({ 'detail': 'Gimme your first name' })

results in

{
    errors: [{
        detail: 'First name is required'
    }]
}

@jerel jerel mentioned this pull request Jul 24, 2015
7 tasks
jsenecal added a commit that referenced this pull request Jul 25, 2015
Added error formating and fixed the tests
@jsenecal jsenecal merged commit 93406e3 into develop Jul 25, 2015
@jerel jerel deleted the feature/errors branch July 25, 2015 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants