src/modules/o_O.model.js in eyeballs-0.5.8.2 vs src/modules/o_O.model.js in eyeballs-0.5.9
- old
+ new
@@ -4,30 +4,33 @@
var callback = callback;
var class_methods, instance_methods, initializer_methods;
var validates_presence_of, validates_length_of;
var table_name = model_name.underscore() + 's';
var initial_class_methods = [];
-
- class_methods = {
- validations: {presence: [], lengthliness: [], custom: []},
- methods: {},
- validates_presence_of: function(field){
- this.validations.presence.push({field: field});
- },
- validates_length_of: function(field, options){
- options.field = field;
- this.validations.lengthliness.push(options);
- },
- validates: function(validation){
- this.validations.custom.push(validation)
+
+ var class_methods = {}
+ if(typeof o_O.validations === 'object')
+ {
+ class_methods = {
+ validations: {presence: [], lengthliness: [], custom: []},
+ methods: {},
+ validates_presence_of: function(field){
+ this.validations.presence.push({field: field});
+ },
+ validates_length_of: function(field, options){
+ options.field = field;
+ this.validations.lengthliness.push(options);
+ },
+ validates: function(validation){
+ this.validations.custom.push(validation)
+ }
}
+ for(var method in o_O.validations.class_methods)
+ {
+ initial_class_methods.push(method);
+ }
}
- for(var method in class_methods)
- {
- initial_class_methods.push(method);
- }
-
var run_callback = function(callback, method, object, response){
try{
if(typeof callback === 'function' && method === 'success')
{
@@ -112,11 +115,14 @@
}
this.save(callback);
},
valid: function(){
this.errors.length = 0;
-
- o_O.validations.run(this);
+
+ if(typeof o_O.validations === 'object')
+ {
+ o_O.validations.run(this);
+ }
if(this.errors.length == 0)
{
return true;
}
\ No newline at end of file