Some coding style fixes
This commit is contained in:
parent
9370a96a2b
commit
dd1e54ffec
|
@ -10,16 +10,17 @@ Validatable.validatesNumericalityOf = getConfigurator('numericality');
|
||||||
Validatable.validatesInclusionOf = getConfigurator('inclusion');
|
Validatable.validatesInclusionOf = getConfigurator('inclusion');
|
||||||
Validatable.validatesExclusionOf = getConfigurator('exclusion');
|
Validatable.validatesExclusionOf = getConfigurator('exclusion');
|
||||||
Validatable.validatesFormatOf = getConfigurator('format');
|
Validatable.validatesFormatOf = getConfigurator('format');
|
||||||
Validatable.validate = function(){
|
Validatable.validate = function () {
|
||||||
args = [].slice.call(arguments);
|
args = [].slice.call(arguments);
|
||||||
var valFn = function(){}; //noop
|
var valFn = function () {}; // noop
|
||||||
if (typeof args[args.length - 1] === 'function'){
|
if (typeof args[args.length - 1] === 'function'){
|
||||||
valFn = args.pop();
|
valFn = args.pop();
|
||||||
}
|
}
|
||||||
wrapperFn = function(attr, conf, err){ return valFn.call( this, err) };
|
wrapperFn = function customValidator(attr, conf, err) {
|
||||||
|
return valFn.call(this, err);
|
||||||
|
};
|
||||||
configure(this, wrapperFn, args)
|
configure(this, wrapperFn, args)
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
// implementation of validators
|
// implementation of validators
|
||||||
var validators = {
|
var validators = {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Anatoliy Chakkaev",
|
"author": "Anatoliy Chakkaev",
|
||||||
"name": "jugglingdb",
|
"name": "jugglingdb",
|
||||||
"description": "ORM for every database: redis, mysql, neo4j, mongodb",
|
"description": "ORM for every database: redis, mysql, neo4j, mongodb",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/1602/jugglingdb"
|
"url": "https://github.com/1602/jugglingdb"
|
||||||
},
|
},
|
||||||
|
|
|
@ -77,7 +77,6 @@ it 'should allow to skip validations', (test) ->
|
||||||
|
|
||||||
test.done()
|
test.done()
|
||||||
|
|
||||||
|
|
||||||
it 'should throw error on save if required', (test) ->
|
it 'should throw error on save if required', (test) ->
|
||||||
user = new User
|
user = new User
|
||||||
|
|
||||||
|
@ -216,7 +215,7 @@ it 'should validate format', (test) ->
|
||||||
test.done()
|
test.done()
|
||||||
|
|
||||||
it 'should validate a field using a custom validator', (test)->
|
it 'should validate a field using a custom validator', (test)->
|
||||||
|
|
||||||
User.validate 'email', (err)-> err("crash") if @email.length is 0
|
User.validate 'email', (err)-> err("crash") if @email.length is 0
|
||||||
|
|
||||||
user = new User validAttributes
|
user = new User validAttributes
|
||||||
|
@ -227,4 +226,4 @@ it 'should validate a field using a custom validator', (test)->
|
||||||
test.ok not user.isValid()
|
test.ok not user.isValid()
|
||||||
|
|
||||||
test.done()
|
test.done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue