From 1bed299f99bd55391c04449c6b6bdbfb8486ccb3 Mon Sep 17 00:00:00 2001 From: Darlinton Prauchner Date: Mon, 12 Dec 2016 13:32:49 -0500 Subject: [PATCH] =?UTF-8?q?Creates=20parameter=20=E2=80=9Cterminal?= =?UTF-8?q?=E2=80=9D=20to=20define=20which=20errors=20should=20be=20return?= =?UTF-8?q?ed=20individually;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 + js/ParamValidation.js | 1 + js/ParamValidation.js.map | 2 +- js/RequestValidator.js | 112 ++++++++++++++-------- js/RequestValidator.js.map | 2 +- tests/unit/RequestValidator.ts | 118 +++++++++++++++++++++++ ts/ParamValidation.ts | 1 + ts/RequestValidator.ts | 166 +++++++++++++++++++++------------ 8 files changed, 304 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index f1d0b69..e68ad67 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ validation: { arrayType: 'valid type', // optional, default null, only works if 'type' property is 'array', check if the array content has valid types, supported types: 'string', 'number', 'boolean', 'numeric' values: ['value1', 'value2'], // optional, default null, validates that parameter value belongs to the provided list, if 'type' is 'array', validates every array element regex: /^Valid regex$/, // optional, default null, validates parameter value against provided regex + terminal: true|false|['type', 'required', 'and so on...'] // optional, default false, when defined as 'true' or array of constraints, returns only error messages associated with this property_name and defined rules format: function(data): data // Function to transform input after validation, see below for more detail } } @@ -229,6 +230,8 @@ validator.disableFailOnFirstError(); server.use(validator.validate.bind(validator)); ``` +It is still possible to determine which errors should be returned individually when `disableFailOnFirstError` is activated. In order to do so, one should define the parameter `terminal` on each property being validated. + ## Development ### Installation diff --git a/js/ParamValidation.js b/js/ParamValidation.js index 7be4101..ac04920 100644 --- a/js/ParamValidation.js +++ b/js/ParamValidation.js @@ -8,6 +8,7 @@ var ParamValidation = (function () { this.arrayType = null; this.values = null; this.regex = null; + this.terminal = false; } return ParamValidation; }()); diff --git a/js/ParamValidation.js.map b/js/ParamValidation.js.map index 708d44a..641c04d 100644 --- a/js/ParamValidation.js.map +++ b/js/ParamValidation.js.map @@ -1 +1 @@ -{"version":3,"file":"ParamValidation.js","sourceRoot":"","sources":["../ts/ParamValidation.ts"],"names":[],"mappings":";AAAA;IAAA;QAEW,aAAQ,GAAY,KAAK,CAAC;QAC1B,QAAG,GAAW,CAAC,CAAC;QAChB,QAAG,GAAW,IAAI,CAAC;QACnB,WAAM,GAAW,IAAI,CAAC;QACtB,cAAS,GAAW,IAAI,CAAC;QACzB,WAAM,GAAU,IAAI,CAAC;QACrB,UAAK,GAAW,IAAI,CAAC;IAEhC,CAAC;IAAD,sBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,uBAAe,kBAU3B,CAAA"} \ No newline at end of file +{"version":3,"file":"ParamValidation.js","sourceRoot":"","sources":["../ts/ParamValidation.ts"],"names":[],"mappings":";AAAA;IAAA;QAEW,aAAQ,GAAY,KAAK,CAAC;QAC1B,QAAG,GAAW,CAAC,CAAC;QAChB,QAAG,GAAW,IAAI,CAAC;QACnB,WAAM,GAAW,IAAI,CAAC;QACtB,cAAS,GAAW,IAAI,CAAC;QACzB,WAAM,GAAU,IAAI,CAAC;QACrB,UAAK,GAAW,IAAI,CAAC;QAErB,aAAQ,GAAQ,KAAK,CAAC;IACjC,CAAC;IAAD,sBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,uBAAe,kBAW3B,CAAA"} \ No newline at end of file diff --git a/js/RequestValidator.js b/js/RequestValidator.js index 59d172b..4ab3383 100644 --- a/js/RequestValidator.js +++ b/js/RequestValidator.js @@ -15,11 +15,13 @@ var RequestValidator = (function () { if (this.customErrorMessages.hasOwnProperty(field) && this.customErrorMessages[field].hasOwnProperty(errorType)) { return { message: this.customErrorMessages[field][errorType], + constraint: errorType, isCustom: true }; } return { message: defaultMessage, + constraint: errorType, isCustom: false }; }; @@ -89,6 +91,9 @@ var RequestValidator = (function () { if (validation.hasOwnProperty('format') && typeof validation.format === 'function') { paramValidation.format = validation.format; } + if (validation.hasOwnProperty('terminal') && (typeof validation.terminal === 'boolean' || validation.terminal instanceof Array)) { + paramValidation.terminal = validation.terminal; + } return paramValidation; }; RequestValidator.prototype.validateFields = function (input, validation, inUrl) { @@ -103,25 +108,31 @@ var RequestValidator = (function () { } delete validation.disallowExtraFields; } - for (var _i = 0, _a = Object.keys(validation); _i < _a.length; _i++) { - var key = _a[_i]; + var _loop_1 = function(key) { var paramValidation = RequestValidator.buildValidationParam(validation[key]); if (paramValidation) { var type = input ? typeof input[key] : undefined; - if (paramValidation.required === true && (!input || type === 'undefined')) { - errorMessages = errorMessages.concat(this.getErrorMessage(key, 'required', "Param " + key + " is required")); - continue; + if (type === 'string' && inUrl && paramValidation.type === 'array') { + input[key] = input[key].split(','); } - if (input) { - if (type === 'string' && inUrl && paramValidation.type === 'array') { - input[key] = input[key].split(','); + errorMessages = errorMessages.concat(this_1.validateField(input, key, type, paramValidation)); + if (errorMessages.length) { + if (this_1.failOnFirstError || paramValidation.terminal === true) { + return "break"; } - errorMessages = errorMessages.concat(this.validateField(input, key, type, paramValidation)); - if (this.failOnFirstError && errorMessages.length) { - break; + if (paramValidation.terminal instanceof Array) { + if (errorMessages.every(function (error) { return paramValidation.terminal.indexOf(error.constraint) !== -1; })) { + return "break"; + } } } } + }; + var this_1 = this; + for (var _i = 0, _a = this.getPrioritizedValidationKeys(validation); _i < _a.length; _i++) { + var key = _a[_i]; + var state_1 = _loop_1(key); + if (state_1 === "break") break; } return errorMessages; } @@ -129,37 +140,64 @@ var RequestValidator = (function () { }; RequestValidator.prototype.validateField = function (input, key, type, paramValidation) { var errorMessages = []; - var typeValidation = { value: input[key], type: paramValidation.type }; - if (RequestValidator.checkType(typeValidation) !== true) { - errorMessages.push(this.getErrorMessage(key, 'type', "Param " + key + " has invalid type (" + paramValidation.type + ")")); - } - if (typeValidation.value !== undefined) { - input[key] = typeValidation.value; - } - if (input[key] instanceof Array - && RequestValidator.checkArrayType(input[key], paramValidation.arrayType) !== true) { - errorMessages.push(this.getErrorMessage(key, 'arrayType', "Param " + key + " has invalid content type (" + paramValidation.arrayType + "[])")); + if (paramValidation.required === true && (!input || type === 'undefined')) { + errorMessages.push(this.getErrorMessage(key, 'required', "Param " + key + " is required")); } - if (RequestValidator.checkLength(input[key], paramValidation.length) !== true) { - errorMessages.push(this.getErrorMessage(key, 'length', "Param " + key + " must have a length of " + paramValidation.length)); - } - if (RequestValidator.checkMin(input[key], paramValidation.min) !== true) { - errorMessages.push(this.getErrorMessage(key, 'min', "Param " + key + " must have a minimum length of " + paramValidation.min)); - } - if (RequestValidator.checkMax(input[key], paramValidation.max) !== true) { - errorMessages.push(this.getErrorMessage(key, 'max', "Param " + key + " must have a maximum length of " + paramValidation.max)); - } - if (RequestValidator.checkValues(input[key], paramValidation.values) !== true) { - errorMessages.push(this.getErrorMessage(key, 'values', "Param " + key + " must belong to [" + paramValidation.values.toString() + "]")); - } - if (input[key] !== undefined && paramValidation.regex && !paramValidation.regex.test(input[key])) { - errorMessages.push(this.getErrorMessage(key, 'regex', "Param " + key + " must match regex " + paramValidation.regex)); + if (input) { + var typeValidation = { value: input[key], type: paramValidation.type }; + if (RequestValidator.checkType(typeValidation) !== true) { + errorMessages.push(this.getErrorMessage(key, 'type', "Param " + key + " has invalid type (" + paramValidation.type + ")")); + } + if (typeValidation.value !== undefined) { + input[key] = typeValidation.value; + } + if (input[key] instanceof Array + && RequestValidator.checkArrayType(input[key], paramValidation.arrayType) !== true) { + errorMessages.push(this.getErrorMessage(key, 'arrayType', "Param " + key + " has invalid content type (" + paramValidation.arrayType + "[])")); + } + if (RequestValidator.checkLength(input[key], paramValidation.length) !== true) { + errorMessages.push(this.getErrorMessage(key, 'length', "Param " + key + " must have a length of " + paramValidation.length)); + } + if (RequestValidator.checkMin(input[key], paramValidation.min) !== true) { + errorMessages.push(this.getErrorMessage(key, 'min', "Param " + key + " must have a minimum length of " + paramValidation.min)); + } + if (RequestValidator.checkMax(input[key], paramValidation.max) !== true) { + errorMessages.push(this.getErrorMessage(key, 'max', "Param " + key + " must have a maximum length of " + paramValidation.max)); + } + if (RequestValidator.checkValues(input[key], paramValidation.values) !== true) { + errorMessages.push(this.getErrorMessage(key, 'values', "Param " + key + " must belong to [" + paramValidation.values.toString() + "]")); + } + if (input[key] !== undefined && paramValidation.regex && !paramValidation.regex.test(input[key])) { + errorMessages.push(this.getErrorMessage(key, 'regex', "Param " + key + " must match regex " + paramValidation.regex)); + } + if (paramValidation.format && input[key] !== undefined) { + input[key] = paramValidation.format(input[key]); + } } - if (paramValidation.format && input[key] !== undefined) { - input[key] = paramValidation.format(input[key]); + if (paramValidation.terminal instanceof Array && errorMessages.length > 0) { + var terminalErrors_1 = []; + errorMessages.forEach(function (error, index) { + if (paramValidation.terminal.indexOf(error.constraint) !== -1) { + terminalErrors_1.push(errorMessages[index]); + } + }); + if (terminalErrors_1.length) { + errorMessages = terminalErrors_1; + } } return errorMessages; }; + RequestValidator.prototype.getPrioritizedValidationKeys = function (validation) { + return Object.keys(validation).sort(function (a, b) { + if (validation[a].terminal && validation[a].terminal !== false) { + return -1; + } + if (validation[b].terminal && validation[b].terminal !== false) { + return 1; + } + return 0; + }); + }; RequestValidator.checkType = function (typeValidation) { var inputType = typeof typeValidation.value; if (inputType === 'undefined') { diff --git a/js/RequestValidator.js.map b/js/RequestValidator.js.map index 5e423de..d42e458 100644 --- a/js/RequestValidator.js.map +++ b/js/RequestValidator.js.map @@ -1 +1 @@ -{"version":3,"file":"RequestValidator.js","sourceRoot":"","sources":["../ts/RequestValidator.ts"],"names":[],"mappings":";AAAA,gCAA8B,mBAAmB,CAAC,CAAA;AAElD,IAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7F,IAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAavE;IAKI,0BA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644 --- a/tests/unit/RequestValidator.ts +++ b/tests/unit/RequestValidator.ts @@ -459,6 +459,124 @@ describe('RequestValidator', () => { ); }); + it('RequestValidator with terminal=true', () => { + validator.disableFailOnFirstError(); + + expected = 'Query: Param name is required'; + validator.validate( + { + route: { + validation: { + query: { + id: {type: 'numeric', required: true, length: 3}, + name: {type: 'string', required: true, length: 4, terminal: true}, + description: {type: 'string', required: true, length: 3} + } + } + }, query: { + id: 'bc', + description: '-' + } + }, + null, test + ); + }); + + it('RequestValidator with terminal=[given constraints]', () => { + validator.disableFailOnFirstError(); + + expected = 'Query: Param description has invalid type (numeric)\n' + + 'Query: Param description must have a length of 3'; + validator.validate( + { + route: { + validation: { + query: { + id: {type: 'numeric', required: true, length: 3}, + name: {type: 'string', required: true, length: 4}, + description: {type: 'numeric', required: true, length: 3, terminal: ['type', 'length']} + } + } + }, query: { + id: 'bc', + description: '--' + } + }, + null, test + ); + }); + + it('RequestValidator with terminal=[given constraints on multiple fields]', () => { + validator.disableFailOnFirstError(); + + expected = 'Query: Param description has invalid type (numeric)\n' + + 'Query: Param description must have a length of 3'; + validator.validate( + { + route: { + validation: { + query: { + id: {type: 'numeric', required: true, length: 3, terminal: true}, + name: {type: 'string', required: true, length: 4}, + description: {type: 'numeric', required: true, length: 3, terminal: ['type', 'length']} + } + } + }, query: { + id: 123, + description: '--' + } + }, + null, test + ); + }); + + it('RequestValidator with terminal=[given constraints on multiple fields] first terminal executed', () => { + validator.disableFailOnFirstError(); + + expected = 'Query: Param id is required'; + validator.validate( + { + route: { + validation: { + query: { + id: {type: 'numeric', required: true, length: 3, terminal: true}, + name: {type: 'string', required: true, length: 4}, + description: {type: 'numeric', required: true, length: 3, terminal: ['type', 'length']} + } + } + }, query: { + description: '--' + } + }, + null, test + ); + }); + + it('RequestValidator with terminal=[given constraints] no terminal error', () => { + validator.disableFailOnFirstError(); + + expected = 'Query: Param id must have a minimum length of 1000\n' + + 'Query: Param name must have a length of 4'; + validator.validate( + { + route: { + validation: { + query: { + id: {type: 'numeric', required: true, length: 3, min: 1000, terminal: ['type', 'length']}, + name: {type: 'string', required: true, length: 4}, + description: {type: 'numeric', required: true, length: 3} + } + } + }, query: { + id: '123', + name: 'abc', + description: '1234' + } + }, + null, test + ); + }); + describe('Disallow extra fields', () => { it('Should not allow extra fields (body)', () => { expected = 'Body: Should not contain extra fields (forbiddenOther, forbiddenAnother)'; diff --git a/ts/ParamValidation.ts b/ts/ParamValidation.ts index d62a34b..2206e14 100644 --- a/ts/ParamValidation.ts +++ b/ts/ParamValidation.ts @@ -8,4 +8,5 @@ export class ParamValidation { public values: any[] = null; // tslint:disable-line:no-any public regex: RegExp = null; public format: (data: T) => T; + public terminal: any = false; } diff --git a/ts/RequestValidator.ts b/ts/RequestValidator.ts index 6036329..0dfd98a 100644 --- a/ts/RequestValidator.ts +++ b/ts/RequestValidator.ts @@ -11,6 +11,7 @@ interface TypeValidation { interface ErrorMessage { message: string; + constraint: string; isCustom: boolean; } @@ -31,11 +32,13 @@ export class RequestValidator { if (this.customErrorMessages.hasOwnProperty(field) && this.customErrorMessages[field].hasOwnProperty(errorType)) { return { message: this.customErrorMessages[field][errorType], + constraint: errorType, isCustom: true }; } return { message: defaultMessage, + constraint: errorType, isCustom: false }; } @@ -131,6 +134,11 @@ export class RequestValidator { paramValidation.format = validation.format; } + // Add "terminal" param + if (validation.hasOwnProperty('terminal') && (typeof validation.terminal === 'boolean' || validation.terminal instanceof Array)) { + paramValidation.terminal = validation.terminal; + } + return paramValidation; } @@ -157,28 +165,26 @@ export class RequestValidator { delete validation.disallowExtraFields; } - for (const key of Object.keys(validation)) { + for (const key of this.getPrioritizedValidationKeys(validation)) { const paramValidation = RequestValidator.buildValidationParam(validation[key]); if (paramValidation) { - // Check "required" param const type = input ? typeof input[key] : undefined; - if (paramValidation.required === true && (!input || type === 'undefined')) { - errorMessages = errorMessages.concat( - this.getErrorMessage(key, 'required', `Param ${key} is required`) - ); - continue; - } - if (input) { - // Parse array from url (comma separated string) - if (type === 'string' && inUrl && paramValidation.type === 'array') { - input[key] = input[key].split(','); - } + // Parse array from url (comma separated string) + if (type === 'string' && inUrl && paramValidation.type === 'array') { + input[key] = input[key].split(','); + } - errorMessages = errorMessages.concat(this.validateField(input, key, type, paramValidation)); - if (this.failOnFirstError && errorMessages.length) { + errorMessages = errorMessages.concat(this.validateField(input, key, type, paramValidation)); + if (errorMessages.length) { + if (this.failOnFirstError || paramValidation.terminal === true) { break; } + if (paramValidation.terminal instanceof Array) { + if (errorMessages.every((error: ErrorMessage) => paramValidation.terminal.indexOf(error.constraint) !== -1)) { + break; + } + } } } } @@ -190,71 +196,107 @@ export class RequestValidator { } private validateField(input: any, key: any, type: any, paramValidation: any): ErrorMessage[] { - const errorMessages: ErrorMessage[] = []; + let errorMessages: ErrorMessage[] = []; - // Check type - const typeValidation = {value: input[key], type: paramValidation.type}; - if (RequestValidator.checkType(typeValidation) !== true) { + // Check if field was informed + if (paramValidation.required === true && (!input || type === 'undefined')) { errorMessages.push( - this.getErrorMessage(key, 'type', `Param ${key} has invalid type (${paramValidation.type})`) + this.getErrorMessage(key, 'required', `Param ${key} is required`) ); } - if (typeValidation.value !== undefined) { - input[key] = typeValidation.value; - } + if (input) { + // Check type + const typeValidation = {value: input[key], type: paramValidation.type}; + if (RequestValidator.checkType(typeValidation) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'type', `Param ${key} has invalid type (${paramValidation.type})`) + ); + } - // Check array content if needed - if (input[key] instanceof Array - && RequestValidator.checkArrayType(input[key], paramValidation.arrayType) !== true) { - errorMessages.push( - this.getErrorMessage(key, 'arrayType', `Param ${key} has invalid content type (${paramValidation.arrayType}[])`) - ); - } + if (typeValidation.value !== undefined) { + input[key] = typeValidation.value; + } - // Check length - if (RequestValidator.checkLength(input[key], paramValidation.length) !== true) { - errorMessages.push( - this.getErrorMessage(key, 'length', `Param ${key} must have a length of ${paramValidation.length}`) - ); - } + // Check array content if needed + if (input[key] instanceof Array + && RequestValidator.checkArrayType(input[key], paramValidation.arrayType) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'arrayType', `Param ${key} has invalid content type (${paramValidation.arrayType}[])`) + ); + } - // Check min - if (RequestValidator.checkMin(input[key], paramValidation.min) !== true) { - errorMessages.push( - this.getErrorMessage(key, 'min', `Param ${key} must have a minimum length of ${paramValidation.min}`) - ); - } + // Check length + if (RequestValidator.checkLength(input[key], paramValidation.length) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'length', `Param ${key} must have a length of ${paramValidation.length}`) + ); + } - // Check max - if (RequestValidator.checkMax(input[key], paramValidation.max) !== true) { - errorMessages.push( - this.getErrorMessage(key, 'max', `Param ${key} must have a maximum length of ${paramValidation.max}`) - ); - } + // Check min + if (RequestValidator.checkMin(input[key], paramValidation.min) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'min', `Param ${key} must have a minimum length of ${paramValidation.min}`) + ); + } - // Check values - if (RequestValidator.checkValues(input[key], paramValidation.values) !== true) { - errorMessages.push( - this.getErrorMessage(key, 'values', `Param ${key} must belong to [${paramValidation.values.toString()}]`) - ); - } + // Check max + if (RequestValidator.checkMax(input[key], paramValidation.max) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'max', `Param ${key} must have a maximum length of ${paramValidation.max}`) + ); + } - // Check regex - if (input[key] !== undefined && paramValidation.regex && !paramValidation.regex.test(input[key])) { - errorMessages.push( - this.getErrorMessage(key, 'regex', `Param ${key} must match regex ${paramValidation.regex}`) - ); + // Check values + if (RequestValidator.checkValues(input[key], paramValidation.values) !== true) { + errorMessages.push( + this.getErrorMessage(key, 'values', `Param ${key} must belong to [${paramValidation.values.toString()}]`) + ); + } + + // Check regex + if (input[key] !== undefined && paramValidation.regex && !paramValidation.regex.test(input[key])) { + errorMessages.push( + this.getErrorMessage(key, 'regex', `Param ${key} must match regex ${paramValidation.regex}`) + ); + } + + // Apply format + if (paramValidation.format && input[key] !== undefined) { + input[key] = paramValidation.format(input[key]); + } } - // Apply format - if (paramValidation.format && input[key] !== undefined) { - input[key] = paramValidation.format(input[key]); + // If terminal errors happened on defined constraints, they should be the only returned + if (paramValidation.terminal instanceof Array && errorMessages.length > 0) { + const terminalErrors: ErrorMessage[] = []; + errorMessages.forEach((error: ErrorMessage, index: number) => { + if (paramValidation.terminal.indexOf(error.constraint) !== -1) { + terminalErrors.push(errorMessages[index]); + } + }); + if (terminalErrors.length) { + errorMessages = terminalErrors; + } } return errorMessages; } + private getPrioritizedValidationKeys(validation: any): string[] { + // Allows to determine an order on which the validation should happen (which fields first) + return Object.keys(validation).sort((a: any, b: any) => { + if (validation[a].terminal && validation[a].terminal !== false) { + return -1; + } + if (validation[b].terminal && validation[b].terminal !== false) { + return 1; + } + + return 0; + }); + } + private static checkType(typeValidation: TypeValidation): boolean { const inputType = typeof typeValidation.value;