Last active
December 24, 2015 13:59
-
-
Save mwmaleks/6808917 to your computer and use it in GitHub Desktop.
study to write js-program
This file contains 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 Backbone = require('backbone'); | |
var _ = require('underscore'); | |
var User = Backbone.Model.extend({ | |
validate: function(attrs, options) { | |
if ( !_.isString(attrs.name)) { | |
return "Имя должно быть строкой"; | |
} | |
if ( !_.isNumber(attrs.age) ) { | |
return "Возраст должен быть целочисленным выражением"; | |
} | |
if ( !_.isString(attrs.position) ) { | |
return ""; | |
} | |
}, | |
setName: function(name) { | |
this.name = name; | |
}, | |
setAge: function(age) { | |
this.age = age; | |
}, | |
setPosition: function (pos) { | |
this.position = pos; | |
}, | |
addAge: function(pos) { | |
this.position = pos; | |
(this.age++) | |
} | |
}); | |
module.exports = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment