Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-auto-api.validation

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-auto-api.validation - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

38

js/tests/test.js

@@ -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() {

25

js/utils/validation.js

@@ -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};

2

package.json
{
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc