Created
April 12, 2012 17:03
-
-
Save ayax79/2369171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Role = Backbone.Model.extend({ | |
| urlRoot: '/roles/rest/roles', | |
| validate: function(atts) { | |
| var errors = []; | |
| if (!atts.name || atts.name === '') { | |
| errors.push({field:'name', message: 'Name is required.'}); | |
| } | |
| if (!atts.userGroups || atts.userGroups.length < 1) { | |
| errors.push({field:'userGroups', message: 'No Users or Groups have been selected.'}); | |
| } | |
| if (!atts.permissions || atts.permissions.length < 1) { | |
| errors.push({field:'permissions', message: 'No Permissions have been selected.'}); | |
| } | |
| if (errors.length > 0) { | |
| return errors; | |
| } | |
| } | |
| }); | |
| var role = new Role({id: 1}); | |
| role.save({ | |
| name: 'foo', | |
| userGroups: [{id: 1}] | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment