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

Commit e68ca33c by Gustav Pursche

Update documentation: node-validator is validator.js now

1 parent ad2d4944
Showing with 4 additions and 4 deletions
...@@ -264,7 +264,7 @@ Model validations, allow you to specify format/content/inheritance valid ...@@ -264,7 +264,7 @@ Model validations, allow you to specify format/content/inheritance valid
Validations are automatically run on `create`, `update` and `save`. You can also call `validate()` to manually validate an instance. Validations are automatically run on `create`, `update` and `save`. You can also call `validate()` to manually validate an instance.
The validations are implemented by [validator][3]. The validations are implemented by [validator.js][3].
```js ```js
var ValidateMe = sequelize.define('Foo', { var ValidateMe = sequelize.define('Foo', {
...@@ -320,7 +320,7 @@ var ValidateMe = sequelize.define('Foo', { ...@@ -320,7 +320,7 @@ var ValidateMe = sequelize.define('Foo', {
Note that where multiple arguments need to be passed to the built-in validation functions, the arguments to be passed must be in an array. But if a single array argument is to be passed, for instance an array of acceptable strings for `isIn`, this will be interpreted as multiple string arguments instead of one array argument. To work around this pass a single-length array of arguments, such as `[['one', 'two']]` as shown above. Note that where multiple arguments need to be passed to the built-in validation functions, the arguments to be passed must be in an array. But if a single array argument is to be passed, for instance an array of acceptable strings for `isIn`, this will be interpreted as multiple string arguments instead of one array argument. To work around this pass a single-length array of arguments, such as `[['one', 'two']]` as shown above.
To use a custom error message instead of that provided by node-validator, use an object instead of the plain value or array of arguments, for example a validator which needs no argument can be given a custom message with To use a custom error message instead of that provided by validator.js, use an object instead of the plain value or array of arguments, for example a validator which needs no argument can be given a custom message with
```js ```js
isInt: { isInt: {
...@@ -339,7 +339,7 @@ isIn: { ...@@ -339,7 +339,7 @@ isIn: {
When using custom validator functions the error message will be whatever message the thrown`Error`object holds. When using custom validator functions the error message will be whatever message the thrown`Error`object holds.
See [the node-validator project][4]for more details on the built in validation methods. See [the validator.js project][4] for more details on the built in validation methods.
**Hint: **You can also define a custom function for the logging part. Just pass a function. The first parameter will be the string that is logged. **Hint: **You can also define a custom function for the logging part. Just pass a function. The first parameter will be the string that is logged.
...@@ -642,6 +642,6 @@ sequelize.define('User', {}, { ...@@ -642,6 +642,6 @@ sequelize.define('User', {}, {
[0]: #configuration [0]: #configuration
[3]: https://github.com/chriso/validator.js [3]: https://github.com/chriso/validator.js
[4]: https://github.com/chriso/node-validator [4]: https://github.com/chriso/validator.js
[5]: /docs/latest/misc#asynchronicity [5]: /docs/latest/misc#asynchronicity
[6]: https://github.com/petkaantonov/bluebird/blob/master/API.md#spreadfunction-fulfilledhandler--function-rejectedhandler----promise [6]: https://github.com/petkaantonov/bluebird/blob/master/API.md#spreadfunction-fulfilledhandler--function-rejectedhandler----promise
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!