Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update README.md

  • Loading branch information...
commit 4ac2afe936fe2a716143c29e7a359a983e069223 1 parent 7049cd7
@mem0master authored
Showing with 3 additions and 72 deletions.
  1. +3 −72 README.md
View
75 README.md
@@ -37,78 +37,9 @@ Check the [documentation of node_validator](https://github.com/chriso/node-valid
Example
-------
-in server/server.js :
-
-```js
-
-//server/server.js
-
-var Validator = Inspect.Validator;
-
-//storing all the errors in an array
-Validator.prototype.error = function (msg) {
- this._errors.push(msg);
- return this;
-}
-
-Validator.prototype.getErrors = function () {
- return this._errors;
-}
-
-var validator = new Validator();
-
-
-
-Meteor.methods({
- addRecord: function (data) {
- // Perform validation
- validator.check(data.title).notNull().isAlphanumeric().len(10, 255);
- validator.check(data.description).notNull();
- //etc.
-
- if (validator.getErrors().length > 0) {
- //handling errors
- //for the sake of simplicity we will send the whole info but
- //I don't recommand sending detailed info to clients since it would
- //"help" potential malicious users to understand the inner working of
- //the validation system put in place, its not like that it will stop them....
-
- throw new Meteor.Error(413, "Something is not right", EJSON.toJSONValue(validator.getErrors()));
- }
-
- return CollectionName.insert(data);
- }
-
-});
-
-```
-
-and in client/app.js
-
-```js
-
-Template.templateName.events({
- 'click .submitEvent': function () {
- Meteor.call(
- "addRecord",
- {title: "---",description:""},
- function (err, result) {
- if (err) {
- console.log(err);
- //we should see an object in console with 4 attributes :
- //details : hold an array with validation error messages
- //error : the number of the error
- //message
- //reason
-
- //display message error etc.
- }
- }
- );
- }
-});
-
-```
+Checkout the example folder, run meteor and click in both fields see what happens.
+Hopefully this project will give you an idea on how to use validator.
+The example run validation on input focus change, make sur to do a last xss sanitization before saving in db since a malicious user can still by pass all the Methods calls.
I don't like Inspect
Please sign in to comment.
Something went wrong with that request. Please try again.