mongoose-auto-api.validation
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -9,2 +9,40 @@ var assert, should, v; | ||
// Required Validation | ||
describe('Required Validation', function() { | ||
var val; | ||
val = v.requiredVal('', 'customer'); | ||
it('Returns object', function() { | ||
return val.should.be.a('object'); | ||
}); | ||
it('Messages and Codes Length', function() { | ||
return assert(val.messages.length === val.codes.length); | ||
}); | ||
it('Required Check', function() { | ||
return assert(val.codes.includes('CUSTOMER_REQUIRED')); | ||
}); | ||
return it('Valid Text', function() { | ||
val = v.requiredVal('test@email.com', 'customer'); | ||
return assert(val.codes.length === 0 && val.messages.length === 0 && val.valid); | ||
}); | ||
}); | ||
// Length Validation | ||
describe('Length Validation', function() { | ||
var val; | ||
val = v.lengthVal('elmo', 8, 'name'); | ||
it('Returns object', function() { | ||
return val.should.be.a('object'); | ||
}); | ||
it('Messages and Codes Length', function() { | ||
return assert(val.messages.length === val.codes.length); | ||
}); | ||
it('Length Check', function() { | ||
return assert(val.codes.includes('NAME_INVALID_LENGTH')); | ||
}); | ||
return it('Valid Text', function() { | ||
val = v.lengthVal('christopher', 'name'); | ||
return assert(val.codes.length === 0 && val.messages.length === 0 && val.valid); | ||
}); | ||
}); | ||
// User Validation | ||
@@ -11,0 +49,0 @@ describe('User Validation', function() { |
@@ -1,2 +0,2 @@ | ||
var camelCase, confirmPassVal, confirmValidation, joinValidations, lenValidation, mailValidation, multiValidations, passVal, passValidation, reqValidation, snakeCase, startCase, titleCase, upperSnakeCase, userVal, validationObject; | ||
var camelCase, confirmPassVal, confirmValidation, joinValidations, lenValidation, lengthVal, mailValidation, multiValidations, passVal, passValidation, reqValidation, requiredVal, snakeCase, startCase, titleCase, upperSnakeCase, userVal, validationObject; | ||
@@ -19,2 +19,23 @@ startCase = require('lodash.startcase'); | ||
//: Required Field Validation | ||
requiredVal = function(text, field) { | ||
return multiValidations(text, field, [ | ||
{ | ||
func: reqValidation | ||
} | ||
]); | ||
}; | ||
//: Field Length Validation | ||
lengthVal = function(text, length, field) { | ||
return multiValidations(text, field, [ | ||
{ | ||
func: lenValidation, | ||
args: { | ||
length: length | ||
} | ||
} | ||
]); | ||
}; | ||
//: User Validation | ||
@@ -158,2 +179,2 @@ userVal = function(text, field) { | ||
module.exports = {userVal, passVal, confirmPassVal, joinValidations}; | ||
module.exports = {userVal, passVal, confirmPassVal, requiredVal, lengthVal, joinValidations}; |
{ | ||
"name": "mongoose-auto-api.validation", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Automatic Mongoose REST API - Validations module", | ||
@@ -5,0 +5,0 @@ "main": "./js/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10777
298