Merge pull request #206 from anatoliychakkaev/master

Documentation improvements
This commit is contained in:
Anatoliy Chakkaev 2013-02-12 01:05:48 -08:00
commit d2376a729a
1 changed files with 31 additions and 0 deletions

View File

@ -134,6 +134,17 @@ Validatable.validatesFormatOf = getConfigurator('format');
* *
* Default error message: is invalid * Default error message: is invalid
* *
* Example:
*
* User.validate('name', customValidator, {message: 'Bad name'});
* function customValidator(err) {
* if (this.name === 'bad') err();
* });
* var user = new User({name: 'Peter'});
* user.isValid(); // true
* user.name = 'bad';
* user.isValid(); // false
*
* @nocode * @nocode
* @see helper/validateCustom * @see helper/validateCustom
*/ */
@ -144,6 +155,26 @@ Validatable.validate = getConfigurator('custom');
* *
* Default error message: is invalid * Default error message: is invalid
* *
* Example:
*
* User.validateAsync('name', customValidator, {message: 'Bad name'});
* function customValidator(err, done) {
* process.nextTick(function () {
* if (this.name === 'bad') err();
* done();
* });
* });
* var user = new User({name: 'Peter'});
* user.isValid(); // false (because async validation setup)
* user.isValid(function (isValid) {
* isValid; // true
* })
* user.name = 'bad';
* user.isValid(); // false
* user.isValid(function (isValid) {
* isValid; // false
* })
*
* @async * @async
* @nocode * @nocode
* @see helper/validateCustom * @see helper/validateCustom