From 9fdca026bf93fd4acfca555b71d4dc174d3b13ef Mon Sep 17 00:00:00 2001 From: Semigradsky Date: Wed, 15 Apr 2015 09:41:30 +0300 Subject: [PATCH] Added more info about examples. Fix `custom-validation` example --- examples/README.md | 25 ++++++++++++++++++++++++- examples/custom-validation/app.js | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/README.md b/examples/README.md index 0b43c49..89a49a3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,4 +6,27 @@ To run and development examples: 1. Clone this repo 2. Run `npm install` 3. Start the development server with `npm run examples` -4. Point your browser to http://localhost:8080 \ No newline at end of file +4. Point your browser to http://localhost:8080 + + +## Possible Issues + +Examples might not run if you have an old node packages. Try clear [npm cache](https://docs.npmjs.com/cli/cache#details) and reinstall dependencies: +``` +rm -rf node_modules +npm cache clean +npm install +npm run examples +``` + +If it is not helped try update your node.js and npm. + +## Examples + +1. [**Login**](http://localhost:8080/login) + + Two required fields with simple validation. + +2. [**Custom Validation**](http://localhost:8080/custom-validation) + + One field with added validation rule (`Formsy.addValidationRule`) and one field with dynamically added validation and error messages. \ No newline at end of file diff --git a/examples/custom-validation/app.js b/examples/custom-validation/app.js index 9689938..6262315 100644 --- a/examples/custom-validation/app.js +++ b/examples/custom-validation/app.js @@ -18,7 +18,7 @@ var validators = { } }; -Formsy.addValidationRule('isYearOfBirth', function (value) { +Formsy.addValidationRule('isYearOfBirth', function (values, value) { value = parseInt(value); if (typeof value !== 'number' || value !== value) { return false;