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

  1. 05 Jun, 2013 5 commits
  2. 03 Jun, 2013 2 commits
  3. 02 Jun, 2013 1 commit
  4. 31 May, 2013 3 commits
  5. 30 May, 2013 6 commits
  6. 29 May, 2013 4 commits
  7. 27 May, 2013 1 commit
  8. 26 May, 2013 3 commits
  9. 25 May, 2013 2 commits
  10. 24 May, 2013 9 commits
  11. 23 May, 2013 2 commits
  12. 22 May, 2013 2 commits
    • Renamed model errors key from _ to __model · cab315a3
      As discussed on IRC. Also add task for 2.0 to change the validate()
      output structure.
      Bart Nagel committed
    • Add model validations option · d5b08b4f
      The existing but unused (as far as I could tell) DAO option `validate`
      can now have member methods which will be called with the model object's
      context after the other (field-specific) validations.
      
      Only custom functions are allowed (since isInt etc wouldn't make sense
      in this context).
      
      As with other custom validations, they are deemed to pass if they throw
      no error, or fail if an error is thrown.
      
      Any error messages collected are added to a '_' member array of the
      validation result object, alongside the arrays named after any fields
      whose validations failed.
      
      Example:
      
      	var Pub = Sequelize.define('Pub', {
      		name: { type: Sequelize.STRING },
      		address: { type: Sequelize.STRING },
      		latitude: {
      			type: Sequelize.INTEGER,
      			allowNull: true,
      			defaultValue: null,
      			validate: { min: -90, max: 90 }
      		},
      		longitude: {
      			type: Sequelize.INTEGER,
      			allowNull: true,
      			defaultValue: null,
      			validate: { min: -180, max: 180 }
      		},
      	}, {
      		validate: {
      			xorCoords: function() {
      				if ((this.latitude === null) === (this.longitude === null)) {
      					throw new Error('Require either both latitude and longitude or neither')
      				}
      			}
      		}
      	})
      
      In this simple case an object fails validation if latitude or longitude
      is given, but not both. If we try to build one with an out of range
      latitude and no longitude, `raging_bullock_arms.validate()`, might
      return
      
      	{
      		'latitude': ['Invalid number: latitude'],
      		'_': ['Require either both latitude and longitude or neither']
      	}
      
      A test is included.
      Bart Nagel committed