Skip to content

Commit

Permalink
Improve the readability of the attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
František Hába committed Mar 14, 2012
1 parent 909e9bf commit 4112c6f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/engines/json/attributes/enum.js
Expand Up @@ -2,10 +2,13 @@
* Enum
*/
var enumAttribute = function(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (attributeValue.indexOf(propertyValue) === -1) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/length.js
Expand Up @@ -2,10 +2,13 @@
* Length
*/
var lengthAttribute = function length(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isString(propertyValue) && propertyValue.length !== attributeValue) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/maxItems.js
Expand Up @@ -2,10 +2,13 @@
* MaxItems
*/
var maxItemsAttribute = function maxItems(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isArray(propertyValue) && propertyValue.length > attributeValue) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/minItems.js
Expand Up @@ -2,10 +2,13 @@
* MinItems
*/
var minItems = function minItems(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isArray(propertyValue) && propertyValue.length < attributeValue) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/minLength.js
Expand Up @@ -2,10 +2,13 @@
* MinLength
*/
var minLengthAttribute = function minLength(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isString(propertyValue) && propertyValue.length < attributeValue) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/minimum.js
Expand Up @@ -2,12 +2,15 @@
* Minimum
*/
var minimumAttribute = function minimum(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isNumber(propertyValue)) {
if ((propertyAttributes.exclusiveMinimum && propertyValue <= attributeValue) || (propertyValue < attributeValue)) {
this.addError();
}
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/pattern.js
Expand Up @@ -2,10 +2,13 @@
* Pattern
*/
var patternAttribute = function pattern(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (isString(propertyValue) && !propertyValue.match(attributeValue)) {
this.addError();
}

return callback();

};

// Export
Expand Down
3 changes: 3 additions & 0 deletions src/engines/json/attributes/required.js
Expand Up @@ -2,10 +2,13 @@
* Required
*/
var requiredAttribute = function required(property, propertyValue, attributeValue, propertyAttributes, callback) {

if (attributeValue && isUndefined(propertyValue)) {
this.addError();
}

return callback();

};

// Export
Expand Down

0 comments on commit 4112c6f

Please sign in to comment.