From 8abce47c8e87a21bb87d597b4d9830b04a71bad3 Mon Sep 17 00:00:00 2001 From: 1602 Date: Mon, 10 Oct 2011 17:39:10 +0400 Subject: [PATCH] Update validations stuff in README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25fcf442..47f4256e 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,20 @@ User.count(cb) user.destroy(cb); // destroy all instances User.destroyAll(cb); + +// Setup validations +User.validatesPresenceOf('name', 'email') +User.validatesLengthOf('password', {min: 5, message: {min: 'Password is too short'}}); +User.validatesInclusionOf('gender', {in: ['male', 'female']}); +User.validatesExclusionOf('domain', {in: ['www', 'billing', 'admin']}); +User.validatesNumericalityOf('age', {int: true}); + +user.isValid() // false +user.errors // hash of errors {attr: [errmessage, errmessage, ...], attr: ...} ``` Read the tests for usage examples: ./test/common_test.js +Validations: ./test/validations_test.js ## Your own database adapter @@ -107,7 +118,7 @@ of course, if you have redis running, you can run ## Package structure -Now all common logic described in ./index.js, and database-specific stuff in ./lib/*.js. It's super-tiny, right? +Now all common logic described in `./lib/*.js`, and database-specific stuff in `./lib/adapters/*.js`. It's super-tiny, right? ## Project status