不要怂,就是干,撸起袖子干!

indent changes based on new code updates

1 parent 9c99552e
......@@ -27,16 +27,16 @@ DaoValidator.prototype.validate = function() {
emitter.emit('success')
})
.error(function(err) {
var error = new Error('Validation error')
error[DaoValidator.RAW_KEY_NAME] = []
var error = new Error('Validation error')
error[DaoValidator.RAW_KEY_NAME] = []
Utils._.each(err, function (value) {
error[DaoValidator.RAW_KEY_NAME].push(value[DaoValidator.RAW_KEY_NAME])
delete value[DaoValidator.RAW_KEY_NAME]
Utils._.extend(error, value)
error[DaoValidator.RAW_KEY_NAME].push(value[DaoValidator.RAW_KEY_NAME])
delete value[DaoValidator.RAW_KEY_NAME]
Utils._.extend(error, value)
})
emitter.emit('success', error)
emitter.emit('success', error)
})
}).run()
}
......@@ -69,7 +69,6 @@ DaoValidator.prototype.hookValidate = function() {
}
// private
var validateModel = function() {
Utils._.each(this.model.__options.validate, function(_validator, validatorType) {
var validator = prepareValidationOfAttribute.call(this, undefined, _validator, validatorType, { omitValue: true })
......@@ -78,11 +77,11 @@ var validateModel = function() {
var next = function(err) {
if (err) {
var error = {};
error[DaoValidator.RAW_KEY_NAME] = err;
var error = {};
error[DaoValidator.RAW_KEY_NAME] = err
var msg = ((err instanceof Error) ? err.message : err)
error[validatorType] = [msg]
var msg = ((err instanceof Error) ? err.message : err)
error[validatorType] = [msg]
emitter.emit('error', error)
} else {
emitter.emit('success')
......@@ -164,7 +163,7 @@ var prepareValidationOfAttribute = function(value, details, validatorType, optio
try {
details.apply(this.model, callArgs)
} catch(ex) {
return next(ex)
return next(ex)
}
if (!isAsync) {
......
......@@ -8,7 +8,7 @@ var chai = require('chai')
chai.Assertion.includeStack = true
describe(Support.getTestDialectTeaser("DaoValidator"), function() {
describe.only('validations', function() {
describe('validations', function() {
var checks = {
is: {
spec: { args: ["[a-z]",'i'] },
......@@ -476,7 +476,7 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
})
})
it('correctly validates using custom validation methods', function(done) {
it.only('correctly validates using custom validation methods', function(done) {
var User = this.sequelize.define('User' + config.rand(), {
name: {
type: Sequelize.STRING,
......@@ -495,6 +495,7 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
var failingUser = User.build({ name : "3" })
failingUser.validate().success(function(errors) {
console.log('ERR:\n', errors, '\n\n', errors.name, '\n\n');
expect(errors).to.deep.equal({ name: ["name should equal '2'"] })
var successfulUser = User.build({ name : "2" })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!