Permalink
Browse files

[minor] Fix whitespaces

  • Loading branch information...
1 parent 6499c54 commit 4239470926b0673aa3fb0fadda2d81e40590e3a2 @pksunkara pksunkara committed Apr 16, 2012
Showing with 18 additions and 18 deletions.
  1. +13 −13 example/webservice.js
  2. +2 −2 lib/revalidator.js
  3. +1 −1 package.json
  4. +2 −2 test/validator-test.js
View
@@ -42,25 +42,25 @@ var revalidator = require('../'),
var server = http.createServer(function validateRestRequest (req, res) {
req.method = req.method.toUpperCase();
-
+
//
// Log the requests
//
console.log(req.method, req.url);
-
+
//
// Buffer the request so it can be parsed as JSON
//
var requestBody = [];
req.on('data', function addDataToBody (data) {
requestBody.push(data);
});
-
+
//
// Once the request has ended work with the body
//
req.on('end', function dealWithRest () {
-
+
//
// Parse the JSON
//
@@ -78,7 +78,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
else {
requestBody = {};
}
-
+
//
// If this was sent to a url but the body url was not declared
// Make sure the body get the requested url so that our schema
@@ -87,7 +87,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
if (!requestBody.url) {
requestBody.url = req.url;
}
-
+
//
// Don't let users override the main API endpoint
//
@@ -96,7 +96,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
res.end('Cannot override the API endpoint "/"');
return;
}
-
+
//
// See if our request and target are out of sync
// This lets us double check the url we are about to take up
@@ -107,7 +107,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
res.end('Requested url and actual url do not match');
return;
}
-
+
//
// Validate the schema
//
@@ -117,7 +117,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
res.end(validation.errors.join('\n'));
return;
}
-
+
//
// Grab the current value from storage and
// check if it is a valid state for REST
@@ -135,7 +135,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
res.end('DOES NOT EXIST');
return;
}
-
+
//
// Check our challenge
//
@@ -144,7 +144,7 @@ var server = http.createServer(function validateRestRequest (req, res) {
res.end('NOT AUTHORIZED');
return;
}
-
+
//
// Since revalidator only checks and does not manipulate
// our object we need to set up the defaults our selves
@@ -154,13 +154,13 @@ var server = http.createServer(function validateRestRequest (req, res) {
if (requestBody.body === undefined) {
requestBody.body = schema.properties.body.default;
}
-
+
//
// Use REST to determine how to manipulate the stored
// values
//
switch (req.method) {
-
+
case "GET":
res.writeHead(200);
var result = storedValue.body;
View
@@ -105,7 +105,7 @@
'email': /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
'ip-address': /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i,
'ipv6': /^([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}$/,
- 'date-time': /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:.\d{1,3})?Z$/,
+ 'date-time': /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:.\d{1,3})?Z$/,
'date': /^\d{4}-\d{2}-\d{2}$/,
'time': /^\d{2}:\d{2}:\d{2}$/,
'color': /^#[a-z0-9]{6}|#[a-z0-9]{3}|(?:rgb\(\s*(?:[+-]?\d+%?)\s*,\s*(?:[+-]?\d+%?)\s*,\s*(?:[+-]?\d+%?)\s*\))aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|and yellow$/i,
@@ -334,7 +334,7 @@
function error(attribute, property, actual, schema, errors) {
var lookup = { expected: schema[attribute], attribute: attribute, property: property };
var message = schema.messages && schema.messages[attribute] || validate.messages[attribute] || "no default message";
- message = message.replace(/%\{([a-z]+)\}/ig, function (_, match) { return lookup[match.toLowerCase()] || ''; });
+ message = message.replace(/%\{([a-z]+)\}/ig, function (_, match) { return lookup[match.toLowerCase()] || ''; });
errors.push({
attribute: attribute,
property: property,
View
@@ -10,7 +10,7 @@
],
"repository": {
"type": "git",
- "url": "http://github.com/flatiron/revalidator.git"
+ "url": "http://github.com/flatiron/revalidator.git"
},
"devDependencies": {
"vows": "0.6.x"
View
@@ -54,7 +54,7 @@ function assertValidates(passingValue, failingValue, attributes) {
}
var attr = Object.keys(attributes)[0];
- revalidator.mixin(schema.properties.field, attributes);
+ revalidator.mixin(schema.properties.field, attributes);
var result = {
"when the object conforms": {
@@ -233,7 +233,7 @@ vows.describe('revalidator', {
topic: function (object, schema) {
return revalidator.validate(object, schema);
},
- "return an object with the `valid` property set to true": assertValid,
+ "return an object with the `valid` property set to true": assertValid,
"return an object with the `errors` property as an empty array": function (res) {
assert.isArray(res.errors);
assert.isEmpty(res.errors);

0 comments on commit 4239470

Please sign in to comment.