Skip to content

Commit

Permalink
Fix spacing in Validation.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni committed Aug 16, 2013
1 parent 34bbb1f commit f0de85f
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/css/Validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
var Validation = {

validate: function(property, value){

//normalize name
var name = property.toString().toLowerCase(),
parts = value.parts,
expression = new PropertyValueIterator(value),
spec = Properties[name],
part,
valid,
valid,
j, count,
msg,
types,
last,
literals,
max, multi, group;

if (!spec) {
if (name.indexOf("-") !== 0){ //vendor prefixed are ok
throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
}
} else if (typeof spec != "number"){

//initialization
if (typeof spec == "string"){
if (spec.indexOf("||") > -1) {
Expand All @@ -41,44 +41,44 @@ var Validation = {
}

},

singleProperty: function(types, expression, max, partial) {

var result = false,
value = expression.value,
count = 0,
part;

while (expression.hasNext() && count < max) {
result = ValidationTypes.isAny(expression, types);
if (!result) {
break;
}
count++;
}

if (!result) {
if (expression.hasNext() && !expression.isFirst()) {
part = expression.peek();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
} else {
throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
}
}
} else if (expression.hasNext()) {
part = expression.next();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
}
},
}

},

multiProperty: function (types, expression, comma, max) {

var result = false,
value = expression.value,
count = 0,
sep = false,
part;

while(expression.hasNext() && !result && count < max) {
if (ValidationTypes.isAny(expression, types)) {
count++;
Expand All @@ -97,27 +97,27 @@ var Validation = {

}
}

if (!result) {
if (expression.hasNext() && !expression.isFirst()) {
part = expression.peek();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
} else {
part = expression.previous();
if (comma && part == ",") {
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
} else {
throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
}
}

} else if (expression.hasNext()) {
part = expression.next();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
}
}

},

groupProperty: function (types, expression, comma) {

var result = false,
Expand All @@ -127,19 +127,19 @@ var Validation = {
partial = false,
name,
part;

while(expression.hasNext() && !result) {
name = ValidationTypes.isAnyOfGroup(expression, types);
if (name) {

//no dupes
if (groups[name]) {
break;
} else {
groups[name] = 1;
groups.count++;
partial = true;

if (groups.count == typeCount || !expression.hasNext()) {
result = true;
}
Expand All @@ -148,8 +148,8 @@ var Validation = {
break;
}
}
if (!result) {

if (!result) {
if (partial && expression.hasNext()) {
part = expression.peek();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
Expand All @@ -159,9 +159,9 @@ var Validation = {
} else if (expression.hasNext()) {
part = expression.next();
throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
}
}
}



};

0 comments on commit f0de85f

Please sign in to comment.