Repository: icebob/fastest-validator
Pull request #61 (2019-02-12 13:52:03)

Update README.md
Add `uuid` documentation
Update coverage table


Patch:
diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index b2026e5..0000000
--- a/.editorconfig
+++ /dev/null
@@ -1,30 +0,0 @@
-# EditorConfig helps developers define and maintain consistent
-# coding styles between different editors and IDEs
-# editorconfig.org
-
-root = true
-
-[*]
-
-# Change these settings to your own preference
-indent_style = tab
-indent_size = 4
-space_after_anon_function = true
-
-# We recommend you to keep these unchanged
-end_of_line = lf
-charset = utf-8
-trim_trailing_whitespace = true
-insert_final_newline = true
-
-[*.md]
-trim_trailing_whitespace = false
-indent_style = space
-indent_size = 4
-
-[{package,bower}.json]
-indent_style = space
-indent_size = 2
-
-[*.js]
-quote_type = "double"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d607ba..9d5661d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,14 +1,3 @@
---------------------------------------------------
-<a name="0.6.14"></a>
-# 0.6.14 (2019-02-07)
-
-## Changes
-- add `uuid` rule by [@intech](https://github.com/intech). [#43](https://github.com/icebob/fastest-validator/issues/43)
-- fix typescript exposing by [@darky](https://github.com/darky). [#58](https://github.com/icebob/fastest-validator/issues/58)
-- add personalised error messages per field by [@ispyinternet](https://github.com/ispyinternet). [#57](https://github.com/icebob/fastest-validator/issues/57)
-- add strict object validation by [@fabioanderegg](https://github.com/fabioanderegg) & [@mbaertschi](https://github.com/mbaertschi). [#47](https://github.com/icebob/fastest-validator/issues/47)
-- linting sources.
-
 --------------------------------------------------
 <a name="0.6.13"></a>
 # 0.6.13 (2019-01-22)
@@ -95,4 +84,4 @@ const schema = {
         }
     }
 };
-```
+```
\ No newline at end of file
diff --git a/README.md b/README.md
index ed0ce5e..9a1d980 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,6 @@
 * 13 built-in validators
 * custom validators
 * nested objects & array handling
-* strict object validation
 * multiple validators
 * customizable error messages
 * programmable error object
@@ -49,7 +48,7 @@ You can install it via [NPM](http://npmjs.org/).
 ```
 $ npm install fastest-validator --save
 ```
-or
+or 
 ```
 $ yarn add fastest-validator
 ```
@@ -57,7 +56,7 @@ $ yarn add fastest-validator
 ## Usage
 
 ### Simple method
-Call the `validate` method with the `object` and the `schema`.
+Call the `validate` method with the `object` and the `schema`. 
 > If performance is important, you won't use this method.
 
 ```js
@@ -77,7 +76,7 @@ console.log(v.validate({ id: 5, name: "John", status: true }, schema));
 console.log(v.validate({ id: 5, name: "Al", status: true }, schema));
 /* Returns an array with errors:
     [
-        {
+        { 
             type: 'stringMin',
             expected: 3,
             actual: 2,
@@ -112,7 +111,7 @@ console.log(check({ id: 5, name: "John", status: true }));
 console.log(check({ id: 2, name: "Adam" }));
 /* Returns an array with errors:
     [
-        {
+        { 
             type: 'required',
             field: 'status',
             message: 'The \'status\' field is required!'
@@ -156,19 +155,6 @@ v.validate({ name: "John" }, schema); // Valid
 v.validate({ age: 42 }, schema); // Fail
 ```
 
-# Strict validation
-Object properties which are not specified on the schema are ignored by default. If you set the `$$strict` option to `true` any aditional properties will result in an `strictObject` error.
-
-```js
-let schema = {
-    name: { type: "string" }, // required
-    $$strict: true // no additional properties allowed
-}
-
-v.validate({ name: "John" }, schema); // Valid
-v.validate({ name: "John", age: 42 }, schema); // Fail
-```
-
 # Multiple validators
 It is possible to define more validators for a field. In this case, only one validator needs to succeed for the field to be valid.
 
@@ -201,7 +187,7 @@ v.validate({ prop: "John" }, schema); // Valid
 ```
 
 ## `array`
-This is an `Array` validator.
+This is an `Array` validator. 
 
 **Simple example with strings:**
 ```js
@@ -240,7 +226,7 @@ let schema = {
     } }
 }
 
-v.validate({
+v.validate({ 
     users: [
         { id: 1, name: "John", status: true },
         { id: 2, name: "Jane", status: true },
@@ -273,7 +259,7 @@ v.validate({ roles: ["guest"] }, schema); // Fail
 
 
 ## `boolean`
-This is a `Boolean` validator.
+This is a `Boolean` validator. 
 
 ```js
 let schema = {
@@ -292,7 +278,7 @@ Property | Default  | Description
 
 
 ## `date`
-This is a `Date` validator.
+This is a `Date` validator. 
 
 ```js
 let schema = {
@@ -309,7 +295,7 @@ Property | Default  | Description
 `convert`  | `false`| if `true` and the type is not `Date`, try to convert with `new Date()`.
 
 ## `email`
-This is an e-mail address validator.
+This is an e-mail address validator. 
 
 ```js
 let schema = {
@@ -327,7 +313,7 @@ Property | Default  | Description
 `mode`   | `quick`  | Checker method. Can be `quick` or `precise`.
 
 ## `enum`
-This is an enum validator.
+This is an enum validator. 
 
 ```js
 let schema = {
@@ -346,7 +332,7 @@ Property | Default  | Description
 
 
 ## `forbidden`
-This validator returns an error if the property exists in the object.
+This validator returns an error if the property exists in the object. 
 
 ```js
 let schema = {
@@ -407,15 +393,15 @@ let schema = {
     } }
 }
 
-v.validate({
+v.validate({ 
     address: {
         country: "Italy",
         city: "Rome",
         zip: 12345
-    }
+    } 
 }, schema); // Valid
 
-v.validate({
+v.validate({ 
     address: {
         country: "Italy",
         city: "Rome"
@@ -423,10 +409,6 @@ v.validate({
 }, schema); // Fail ("The 'address.zip' field is required!")
 ```
 
-### Properties
-Property | Default  | Description
--------- | -------- | -----------
-`strict`  | `false`| if `true` any properties which are not defined on the schema will throw an error.
 
 ## `string`
 This is a `String`.
@@ -458,7 +440,7 @@ Property | Default  | Description
 
 
 ## `url`
-This is an URL validator.
+This is an URL validator. 
 
 ```js
 let schema = {
@@ -470,6 +452,23 @@ v.validate({ url: "https://github.com/icebob" }, schema); // Valid
 v.validate({ url: "www.facebook.com" }, schema); // Fail
 ```
 
+## `uuid`
+This is an UUID validator. 
+
+```js
+let schema = {
+    uuid: { type: "uuid" }
+}
+
+v.validate({ uuid: "10ba038e-48da-487b-96e8-8d3b99b6d18a" }, schema); // Valid UUIDv4
+v.validate({ uuid: "9a7b330a-a736-51e5-af7f-feaf819cdc9f" }, schema); // Valid UUIDv5
+v.validate({ uuid: "10ba038e-48da-487b-96e8-8d3b99b6d18a", version: 5 }, schema); // Fail
+```
+### Properties
+Property | Default  | Description
+-------- | -------- | -----------
+`version`  | `4`   | UUID version in range 1-5.
+
 # Custom validator
 You can also create your custom validator.
 
@@ -520,9 +519,9 @@ let v = new Validator({
 
 const schema = {
 	name: { type: "string", min: 3, max: 255 },
-	weight: {
-		type: "custom",
-		minWeight: 10,
+	weight: { 
+		type: "custom", 
+		minWeight: 10, 
 		check(value, schema) {
 			return (value < schema.minWeight)
 				? this.makeError("weightMin", schema.minWeight, value)
@@ -536,12 +535,12 @@ console.log(v.validate({ name: "John", weight: 50 }, schema));
 
 console.log(v.validate({ name: "John", weight: 8 }, schema));
 /* Returns an array with errors:
-	[{
-		type: 'weightMin',
-		expected: 10,
-		actual: 8,
-		field: 'weight',
-		message: 'The weight must be greater than 10! Actual: 8'
+	[{ 
+		type: 'weightMin',                                       
+		expected: 10,                                            
+		actual: 8,                                               
+		field: 'weight',                                         
+		message: 'The weight must be greater than 10! Actual: 8' 
 	}]
 */
 ```
@@ -560,61 +559,18 @@ const v = new Validator({
 
 v.validate({ name: "John" }, { name: { type: "string", min: 6 }});
 /* Returns:
-[
-    {
+[ 
+    { 
         type: 'stringMin',
         expected: 6,
         actual: 4,
         field: 'name',
-        message: 'A(z) \'name\' mező túl rövid. Minimum: 6, Jelenleg: 4'
-    }
+        message: 'A(z) \'name\' mező túl rövid. Minimum: 6, Jelenleg: 4' 
+    } 
 ]
 */
 ```
-# Personalised Messages
-Sometimes the standard messages are too generic. You can customise messages per validation type per field:
 
-```js
-const Validator = require("fastest-validator");
-const v = new Validator();
-const schema = {
-    firstname: {
-        type: "string",
-        min: 6,
-        messages: {
-            string: "Please check your firstname",
-            stringMin: "Your firstname is too short"
-        }
-    },
-    lastname: {
-        type: "string",
-        min: 6,
-        messages: {
-            string: "Please check your lastname",
-            stringMin: "Your lastname is too short"
-        }
-    }
-}
-v.validate({ firstname: "John", lastname: 23 }, schema );
-/* Returns:
-[
-    {
-        type: 'stringMin',
-        expected: 6,
-        actual: 4,
-        field: 'firstname',
-        message: 'Your firstname is too short'
-    },
-    {
-        type: 'string',
-        expected: undefined,
-        actual: undefined,
-        field: 'lastname',
-        message: 'Please check your lastname'
-    }
-]
-*/
-```
 ## Message types
 Name                | Default text
 ------------------- | -------------
@@ -670,26 +626,32 @@ npm test
 
 ### Coverage report
 ```
----------------|----------|----------|----------|----------|----------------|
-File           |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------------|----------|----------|----------|----------|----------------|
-All files      |      100 |      100 |      100 |      100 |                |
- lib           |      100 |      100 |      100 |      100 |                |
-  messages.js  |      100 |      100 |      100 |      100 |                |
-  validator.js |      100 |      100 |      100 |      100 |                |
- lib/rules     |      100 |      100 |      100 |      100 |                |
-  any.js       |      100 |      100 |      100 |      100 |                |
-  array.js     |      100 |      100 |      100 |      100 |                |
-  boolean.js   |      100 |      100 |      100 |      100 |                |
-  date.js      |      100 |      100 |      100 |      100 |                |
-  email.js     |      100 |      100 |      100 |      100 |                |
-  forbidden.js |      100 |      100 |      100 |      100 |                |
-  function.js  |      100 |      100 |      100 |      100 |                |
-  number.js    |      100 |      100 |      100 |      100 |                |
-  object.js    |      100 |      100 |      100 |      100 |                |
-  string.js    |      100 |      100 |      100 |      100 |                |
-  url.js       |      100 |      100 |      100 |      100 |                |
----------------|----------|----------|----------|----------|----------------|
+-----------------|----------|----------|----------|----------|-------------------|
+File             |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
+-----------------|----------|----------|----------|----------|-------------------|
+All files        |      100 |      100 |      100 |      100 |                   |
+ lib             |      100 |      100 |      100 |      100 |                   |
+  messages.js    |      100 |      100 |      100 |      100 |                   |
+  validator.js   |      100 |      100 |      100 |      100 |                   |
+ lib/helpers     |      100 |      100 |      100 |      100 |                   |
+  deep-extend.js |      100 |      100 |      100 |      100 |                   |
+  flatten.js     |      100 |      100 |      100 |      100 |                   |
+ lib/rules       |      100 |      100 |      100 |      100 |                   |
+  any.js         |      100 |      100 |      100 |      100 |                   |
+  array.js       |      100 |      100 |      100 |      100 |                   |
+  boolean.js     |      100 |      100 |      100 |      100 |                   |
+  custom.js      |      100 |      100 |      100 |      100 |                   |
+  date.js        |      100 |      100 |      100 |      100 |                   |
+  email.js       |      100 |      100 |      100 |      100 |                   |
+  enum.js        |      100 |      100 |      100 |      100 |                   |
+  forbidden.js   |      100 |      100 |      100 |      100 |                   |
+  function.js    |      100 |      100 |      100 |      100 |                   |
+  number.js      |      100 |      100 |      100 |      100 |                   |
+  object.js      |      100 |      100 |      100 |      100 |                   |
+  string.js      |      100 |      100 |      100 |      100 |                   |
+  url.js         |      100 |      100 |      100 |      100 |                   |
+  uuid.js        |      100 |      100 |      100 |      100 |                   |
+-----------------|----------|----------|----------|----------|-------------------|
 ```
 
 ## Contribution
diff --git a/benchmark/suites/simple.js b/benchmark/suites/simple.js
index 04ff9fe..a6482af 100644
--- a/benchmark/suites/simple.js
+++ b/benchmark/suites/simple.js
@@ -32,27 +32,7 @@ const schema = {
 	},
 	email: { type: "email" },
 	firstName: { type: "string" },
-	phone: { type: "string"},
-	age: {
-		type: "number",
-		min: 18
-	}
-};
-
-const schema2 = {
-	name: {
-		type: "string",
-		min: 4,
-		max: 25,
-		messages: {
-			string: "Csak szöveges érték",
-			stringMin: "Túl rövid!",
-			stringMax: "Túl hosszú"
-		}
-	},
-	email: { type: "email" },
-	firstName: { type: "string" },
-	phone: { type: "string"},
+	phone: { type: "string" },
 	age: {
 		type: "number",
 		min: 18
@@ -60,27 +40,22 @@ const schema2 = {
 };
 
 bench.ref("compile & validate", () => {
-	const res = v.validate(obj, schema);
+	let res = v.validate(obj, schema);		
 	if (res !== true)
 		throw new Error("Validation error!", res);
 });
 
-bench.add("compile & validate with custom messages", () => {
-	const res = v.validate(obj, schema2);
-	if (res !== true)
-		throw new Error("Validation error!", res);
-});
 
-const check = v.compile(schema);
+let check = v.compile(schema);
 
 bench.add("validate with pre-compiled schema", () => {
-	const res = check(obj);
+	let res = check(obj);
 	if (res !== true)
 		throw new Error("Validation error!", res);
 });
 
 bench.add("validate with wrong obj", () => {
-	const res = check(wrongObj);
+	let res = check(wrongObj);
 	if (res === true)
 		throw new Error("Validation error!", res);
 });
@@ -111,4 +86,4 @@ Suite: Simple object
    validate with wrong obj                 -36.79%        (704,992 rps)   (avg: 1μs)
 -----------------------------------------------------------------------
 
-*/
+*/
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
index 384480d..f8ebd31 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -22,7 +22,7 @@ declare interface ValidationRuleObject {
     convert?: boolean;
     items?: string;
     props?: ValidationSchema;
-    check?: (value: any, schema: ValidationSchema) => boolean | ValidationResult;
+    check?: (value: any, ValidationSchema) => boolean | ValidationResult;
 }
 
 declare type ValidationRule = ValidationRuleObject | ValidationRuleObject[] | string;
diff --git a/lib/messages.js b/lib/messages.js
index 6a3f8ab..4e2e54b 100644
--- a/lib/messages.js
+++ b/lib/messages.js
@@ -49,8 +49,6 @@ module.exports = {
 
 	enumValue: "The '{field} field value '{expected}' does not match any of the allowed values!",
 
-	object: "The '{field}' must be an Object!",
-	objectStrict: "The object '{field}' contains invalid keys: '{actual}'!",
 	uuid: "The {field} field must be a valid UUID",
 	uuidVersion: "The {field} field must be a valid version provided",
 };
\ No newline at end of file
diff --git a/lib/rules/email.js b/lib/rules/email.js
index b207104..3345d41 100644
--- a/lib/rules/email.js
+++ b/lib/rules/email.js
@@ -1,6 +1,6 @@
 "use strict";
 
-const PRECISE_PATTERN = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+const PRECISE_PATTERN = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 const BASIC_PATTERN = /^\S+@\S+\.\S+$/;
 
 module.exports = function checkEmail(value, schema) {
@@ -13,7 +13,7 @@ module.exports = function checkEmail(value, schema) {
 		pattern = PRECISE_PATTERN;
 	else
 		pattern = BASIC_PATTERN;
-
+	
 	if (!pattern.test(value)) {
 		return this.makeError("email");
 	}
diff --git a/lib/rules/object.js b/lib/rules/object.js
index 9b7be29..43c01ee 100644
--- a/lib/rules/object.js
+++ b/lib/rules/object.js
@@ -1,24 +1,9 @@
 "use strict";
 
-module.exports = function checkObject(value, schema) {
+module.exports = function checkObject(value) {
 	if (typeof value !== "object" || value === null || Array.isArray(value)) {
 		return this.makeError("object");
 	}
 
-	if (schema.strict === true && schema.props) {
-		const allowedProps = Object.keys(schema.props);
-		const invalidProps = [];
-		const props = Object.keys(value);
-
-		for (let i = 0; i < props.length; i++) {
-			if (allowedProps.indexOf(props[i]) === -1) {
-				invalidProps.push(props[i]);
-			}
-		}
-		if (invalidProps.length !== 0) {
-			return this.makeError("objectStrict", undefined, invalidProps.join(", "));
-		}
-	}
-
 	return true;
 };
\ No newline at end of file
diff --git a/lib/rules/string.js b/lib/rules/string.js
index ee275f5..2f3b5b2 100644
--- a/lib/rules/string.js
+++ b/lib/rules/string.js
@@ -3,7 +3,7 @@
 const NUMERIC_PATTERN = /^-?[0-9]\d*(\.\d+)?$/;
 const ALPHA_PATTERN = /^[a-zA-Z]+$/;
 const ALPHANUM_PATTERN = /^[a-zA-Z0-9]+$/;
-const ALPHADASH_PATTERN = /^[a-zA-Z0-9_-]+$/;
+const ALPHADASH_PATTERN = /^[a-zA-Z0-9_\-]+$/;
 
 module.exports = function checkString(value, schema) {
 	if (typeof value !== "string") {
@@ -26,7 +26,7 @@ module.exports = function checkString(value, schema) {
 
 	if (schema.length != null && valueLength !== schema.length) {
 		return this.makeError("stringLength", schema.length, valueLength);
-	}
+	}	
 
 	if (schema.pattern != null) {
 		const pattern = typeof schema.pattern == "string" ? new RegExp(schema.pattern, schema.patternFlags) : schema.pattern;
@@ -36,7 +36,7 @@ module.exports = function checkString(value, schema) {
 
 	if (schema.contains != null && value.indexOf(schema.contains) === -1) {
 		return this.makeError("stringContains", schema.contains);
-	}
+	}	
 
 	if (schema.enum != null && schema.enum.indexOf(value) === -1) {
 		return this.makeError("stringEnum", schema.enum);
@@ -59,4 +59,4 @@ module.exports = function checkString(value, schema) {
 	}
 
 	return true;
-};
+};
\ No newline at end of file
diff --git a/lib/validator.js b/lib/validator.js
index 07a0b1e..18492e0 100644
--- a/lib/validator.js
+++ b/lib/validator.js
@@ -32,7 +32,7 @@ const escapeEvalRegex = /["'\\\n\r\u2028\u2029]/g;
 
 function escapeEvalString(str) {
 	// Based on https://github.com/joliss/js-string-escape
-	return str.replace(escapeEvalRegex, function(character) {
+	return str.replace(escapeEvalRegex, function (character) {
 		switch (character) {
 		case "\"":
 		case "'":
@@ -65,7 +65,6 @@ function Validator(opts) {
 		deepExtend(this.opts, opts);
 
 	this.messages = this.opts.messages;
-	this.messageKeys = Object.keys(this.messages);
 
 	// Load rules
 	this.rules = loadRules();
@@ -92,7 +91,7 @@ Validator.prototype.validate = function(obj, schema) {
 Validator.prototype.compile = function(schema) {
 	const self = this;
 	if (Array.isArray(schema)) {
-	// Multiple schemas
+		// Multiple schemas
 		if (schema.length == 0) {
 			throw new Error("If the schema is an Array, must contain at least one element!");
 		}
@@ -102,7 +101,7 @@ Validator.prototype.compile = function(schema) {
 		return function(value, path, parent) {
 			return self.checkSchemaType(value, rules, path, parent || null);
 		};
-	}
+	} 
 
 	const rule = this.compileSchemaObject(schema);
 	this.cache.clear();
@@ -116,32 +115,24 @@ Validator.prototype.compileSchemaObject = function(schemaObject) {
 		throw new Error("Invalid schema!");
 	}
 
-	const strict = schemaObject.$$strict;
-	delete schemaObject.$$strict;
-
 	let compiledObject = this.cache.get(schemaObject);
 	if (compiledObject) {
 		compiledObject.cycle = true;
 		return compiledObject;
-	} else {
+	} else{
 		compiledObject = { cycle: false, properties: null, compiledObjectFunction: null, objectStack: [] };
 		this.cache.set(schemaObject, compiledObject);
 	}
 
 	compiledObject.properties = Object.keys(schemaObject).map(name => {
 		const compiledType = this.compileSchemaType(schemaObject[name]);
-		return { name: name, compiledType: compiledType };
+		return {name: name, compiledType: compiledType};
 	});
 
 	const sourceCode = [];
 	sourceCode.push("let res;");
 	sourceCode.push("let propertyPath;");
 	sourceCode.push("const errors = [];");
-
-	if (strict === true) {
-		sourceCode.push("const givenProps = new Map(Object.keys(value).map(key => [key, true]));");
-	}
-
 	for (let i = 0; i < compiledObject.properties.length; i++) {
 		const property = compiledObject.properties[i];
 		const name = escapeEvalString(property.name);
@@ -154,17 +145,7 @@ Validator.prototype.compileSchemaObject = function(schemaObject) {
 			sourceCode.push(`res = this.checkSchemaRule(${propertyValueExpr}, properties[${i}].compiledType, propertyPath, value);`);
 		}
 		sourceCode.push("if (res !== true) {");
-		sourceCode.push(`\tthis.handleResult(errors, propertyPath, res, properties[${i}].compiledType.messages);`);
-		sourceCode.push("}");
-
-		if (strict === true) {
-			sourceCode.push(`givenProps.delete("${name}");`);
-		}
-	}
-
-	if (strict === true) {
-		sourceCode.push("if (givenProps.size !== 0) {");
-		sourceCode.push("\tthis.handleResult(errors, path || 'rootObject', this.makeError('objectStrict', undefined, [...givenProps.keys()].join(', ')), this.messages);");
+		sourceCode.push("\tthis.handleResult(errors, propertyPath, res);");
 		sourceCode.push("}");
 	}
 
@@ -176,12 +157,9 @@ Validator.prototype.compileSchemaObject = function(schemaObject) {
 };
 
 Validator.prototype.compileSchemaType = function(schemaType) {
-
 	if (Array.isArray(schemaType)) {
-
 		// Multiple rules, flatten to array of compiled SchemaRule
 		const rules = flatten(schemaType.map(r => this.compileSchemaType(r)));
-
 		if (rules.length == 1) {
 			return rules[0];
 		}
@@ -190,23 +168,9 @@ Validator.prototype.compileSchemaType = function(schemaType) {
 	}
 
 	return this.compileSchemaRule(schemaType);
-
-};
-
-Validator.prototype.compileMessages = function(schemaType) {
-
-	if (schemaType.messages) {
-		return this.messageKeys.reduce((a, key) => {
-			a[key] = schemaType.messages[key] || this.messages[key];
-			return a;
-		}, {});
-	}
-
-	return this.messages;
 };
 
 Validator.prototype.compileSchemaRule = function(schemaRule) {
-
 	if (typeof schemaRule === "string") {
 		schemaRule = {
 			type: schemaRule
@@ -214,13 +178,10 @@ Validator.prototype.compileSchemaRule = function(schemaRule) {
 	}
 
 	const ruleFunction = this.rules[schemaRule.type];
-
 	if (!ruleFunction) {
 		throw new Error("Invalid '" + schemaRule.type + "' type in validator schema!");
 	}
 
-	const messages = this.compileMessages(schemaRule);
-
 	let dataParameter = null;
 	let dataFunction = null;
 
@@ -233,7 +194,6 @@ Validator.prototype.compileSchemaRule = function(schemaRule) {
 	}
 
 	return {
-		messages: messages,
 		schemaRule: schemaRule,
 		ruleFunction: ruleFunction,
 		dataFunction: dataFunction,
@@ -260,28 +220,26 @@ Validator.prototype.checkSchemaObjectInner = function(value, compiledObject, pat
 	return compiledObject.compiledObjectFunction.call(this, value, compiledObject.properties, path, parent);
 
 	/*
-    // Reference implementation of the object checker
-
-    const errors = [];
-    const propertiesLength = compiledObject.properties.length;
-    for (let i = 0; i < propertiesLength; i++) {
-    const property = compiledObject.properties[i];
-    const propertyPath = (path !== undefined ? path + "." : "") + property.name;
-    const res = this.checkSchemaType(value[property.name], property.compiledType, propertyPath, value);
-
-    if (res !== true) {
-    this.handleResult(errors, propertyPath, res);
-    }
-    }
-
-    return errors.length === 0 ? true : errors;
-    */
+	// Reference implementation of the object checker
+
+	const errors = [];
+	const propertiesLength = compiledObject.properties.length;
+	for (let i = 0; i < propertiesLength; i++) {
+		const property = compiledObject.properties[i];
+		const propertyPath = (path !== undefined ? path + "." : "") + property.name;
+		const res = this.checkSchemaType(value[property.name], property.compiledType, propertyPath, value);
+
+		if (res !== true) {
+			this.handleResult(errors, propertyPath, res);
+		}
+	}
+
+	return errors.length === 0 ? true : errors;
+	*/
 };
 
 Validator.prototype.checkSchemaType = function(value, compiledType, path, parent) {
-
 	if (Array.isArray(compiledType)) {
-
 		const errors = [];
 		const checksLength = compiledType.length;
 		for (let i = 0; i < checksLength; i++) {
@@ -289,7 +247,7 @@ Validator.prototype.checkSchemaType = function(value, compiledType, path, parent
 			const res = this.checkSchemaRule(value, compiledType[i], path, parent);
 
 			if (res !== true) {
-				this.handleResult(errors, path, res, compiledType.messages);
+				this.handleResult(errors, path, res);
 			} else {
 				// Jump out after first success and clear previous errors
 				return true;
@@ -297,7 +255,7 @@ Validator.prototype.checkSchemaType = function(value, compiledType, path, parent
 		}
 
 		return errors;
-	}
+	} 
 
 	return this.checkSchemaRule(value, compiledType, path, parent);
 };
@@ -311,7 +269,7 @@ Validator.prototype.checkSchemaArray = function(value, compiledArray, path, pare
 		const res = this.checkSchemaType(value[i], compiledArray, itemPath, value, parent);
 
 		if (res !== true) {
-			this.handleResult(errors, itemPath, res, compiledArray.messages);
+			this.handleResult(errors, itemPath, res);
 		}
 	}
 
@@ -329,17 +287,14 @@ Validator.prototype.checkSchemaRule = function(value, compiledRule, path, parent
 			return true;
 
 		const errors = [];
-		this.handleResult(errors, path, this.makeError("required"), compiledRule.messages);
-
+		this.handleResult(errors, path, this.makeError("required"));
 		return errors;
 	}
 
 	const res = compiledRule.ruleFunction.call(this, value, schemaRule, path, parent);
-
 	if (res !== true) {
 		const errors = [];
-		this.handleResult(errors, path, res, compiledRule.messages);
-
+		this.handleResult(errors, path, res);
 		return errors;
 	}
 
@@ -357,7 +312,7 @@ Validator.prototype.checkSchemaRule = function(value, compiledRule, path, parent
  * @param {String} fieldPath
  * @param {Array|Object} res
  */
-Validator.prototype.handleResult = function(errors, fieldPath, res, messages) {
+Validator.prototype.handleResult = function(errors, fieldPath, res) {
 	let items;
 	if (!Array.isArray(res))
 		items = [res];
@@ -368,7 +323,7 @@ Validator.prototype.handleResult = function(errors, fieldPath, res, messages) {
 		if (!err.field)
 			err.field = fieldPath;
 		if (!err.message)
-			err.message = this.resolveMessage(err, messages[err.type]);
+			err.message = this.resolveMessage(err);
 
 		errors.push(err);
 	});
@@ -394,8 +349,8 @@ Validator.prototype.makeError = function(type, expected, actual) {
  *
  * @param {Object} err Validation error object
  */
-Validator.prototype.resolveMessage = function(err, msg = null) {
-
+Validator.prototype.resolveMessage = function(err) {
+	let msg = this.messages[err.type];
 	if (msg != null) {
 		const expected = err.expected != null ? err.expected : "";
 		const actual = err.actual != null ? err.actual : "";
diff --git a/package-lock.json b/package-lock.json
index 97a218d..057b18f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "fastest-validator",
-  "version": "0.6.14",
+  "version": "0.6.13",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
diff --git a/package.json b/package.json
index a327366..6a2e32f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "fastest-validator",
-  "version": "0.6.14",
+  "version": "0.6.13",
   "description": "The fastest JS validator library for NodeJS",
   "main": "dist/index.js",
   "browser": "dist/index.min.js",
@@ -11,8 +11,7 @@
     "dev": "nodemon examples/index.js",
     "ci": "jest --watch",
     "test": "jest --coverage",
-    "lint": "eslint --ext=.js lib test rollup.config.js",
-    "lint:fix": "eslint --fix --ext=.js lib test rollup.config.js",
+    "lint": "eslint --ext=.js src test rollup.config.js",
     "deps": "npm-check -u",
     "coverall": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
   },
@@ -30,8 +29,7 @@
     "dist",
     "examples",
     "lib",
-    "index.js",
-    "index.d.ts"
+    "index.js"
   ],
   "author": "Icebob",
   "license": "MIT",


Test patch:
diff --git a/test/messages.spec.js b/test/messages.spec.js
index 251c6b0..ae6aabb 100644
--- a/test/messages.spec.js
+++ b/test/messages.spec.js
@@ -39,8 +39,6 @@ describe("Test Messages", () => {
 		expect(msg.forbidden).toBeDefined();
 		expect(msg.email).toBeDefined();
 		expect(msg.url).toBeDefined();
-		expect(msg.object).toBeDefined();
-		expect(msg.objectStrict).toBeDefined();
 		expect(msg.uuid).toBeDefined();
 		expect(msg.uuidVersion).toBeDefined();
 
diff --git a/test/rules/custom_messages.spec.js b/test/rules/custom_messages.spec.js
deleted file mode 100644
index 8af661b..0000000
--- a/test/rules/custom_messages.spec.js
+++ /dev/null
@@ -1,101 +0,0 @@
-"use strict";
-
-const Validator = require("../../lib/validator");
-const v = new Validator();
-
-describe("Test custom messages", () => {
-
-	it("should give back not a string message", () => {
-
-		const message = "That wasn't a string!";
-		const s = { name: { type: "string", messages: { string: message } } };
-
-		expect(v.validate({ name: 123 }, s)).toEqual([{ type: "string", expected: undefined, actual: undefined, field: "name", message }]);
-
-	});
-
-	it("should give back required message", () => {
-
-		const message = "Your name is required!";
-
-		const s = { name: { type: "string", messages: { required: message } } };
-
-		expect(v.validate({}, s)).toEqual([{ type: "required", expected: undefined, actual: undefined, field: "name", message: message }]);
-
-	});
-
-	it("should do replacements in custom messages", () => {
-
-		const message = "Incorrect name length. Your field: {field} had {actual} chars when it should have no more than {expected}";
-		const s = { name: { type: "string", max: 2, messages: { stringMax: message } } };
-
-		expect(v.validate({ name: "Long string" }, s)).toEqual([{ type: "stringMax", expected: 2, actual: 11, field: "name", message: "Incorrect name length. Your field: name had 11 chars when it should have no more than 2" }]);
-
-	});
-
-	it("should do custom messages in arrays", () => {
-
-		const s = {
-			cache: [
-				{ type: "string", messages: { string: "Not a string" } },
-				{ type: "boolean", messages: { boolean: "Not a boolean" } }
-			]
-		};
-
-		expect(v.validate({ cache: 123 }, s)).toEqual([{ type: "string", field: "cache", message: "Not a string" }, { type: "boolean", field: "cache", message: "Not a boolean" }]);
-
-	});
-
-	it("should do custom messages in objects", () => {
-
-		const s = {
-			users: {
-				type: "array",
-				items: {
-					type: "object",
-					props: {
-						id: { type: "number", positive: true, messages: { "number": "numbers only please" } },
-						name: { type: "string", empty: false, messages: { "string": "make sure it's a string" } },
-						status: "boolean"
-					}
-				}
-			}
-		};
-
-		expect(v.validate({
-			users: [
-				{ id: "test", name: "John", status: true },
-				{ id: 2, name: 123, status: true },
-				{ id: 3, name: "Bill", status: false }
-			]
-		}, s)).toEqual([{ type: "number", field: "users[0].id", message: "numbers only please" }, { type: "string", field: "users[1].name", message: "make sure it's a string" }]);
-
-	});
-
-	it("should do custom messages when compiled", () => {
-		const s = {
-			users: {
-				type: "array",
-				items: {
-					type: "object",
-					props: {
-						id: { type: "number", positive: true, messages: { "number": "numbers only please" } },
-						name: { type: "string", empty: false, messages: { "string": "make sure it's a string" } },
-						status: "boolean"
-					}
-				}
-			}
-		};
-
-		const check = v.compile(s);
-
-		expect(check({
-			users: [
-				{ id: "test", name: "John", status: true },
-				{ id: 2, name: 123, status: true },
-				{ id: 3, name: "Bill", status: false }
-			]
-		})).toEqual([{ type: "number", field: "users[0].id", message: "numbers only please" }, { type: "string", field: "users[1].name", message: "make sure it's a string" }]);
-
-	});
-});
diff --git a/test/rules/object.spec.js b/test/rules/object.spec.js
index 55b357e..dcacb35 100644
--- a/test/rules/object.spec.js
+++ b/test/rules/object.spec.js
@@ -11,9 +11,7 @@ describe("Test checkObject", () => {
 	it("should check values", () => {
 		const s = { type: "object" };
 		const err = { type: "object" };
-		const strict = { type: "object", strict: true, props: { a: "string" } };
-		const strictErr = {type: "objectStrict" };
-
+		
 		expect(check(null, s)).toEqual(err);
 		expect(check(undefined, s)).toEqual(err);
 		expect(check(0, s)).toEqual(err);
@@ -23,7 +21,5 @@ describe("Test checkObject", () => {
 		expect(check(true, s)).toEqual(err);
 		expect(check([], s)).toEqual(err);
 		expect(check({}, s)).toEqual(true);
-		expect(check({a: "string"}, strict)).toEqual(true);
-		expect(check({a: "string", b: "string"}, strict)).toMatchObject(strictErr);
 	});
 });
diff --git a/test/validator.spec.js b/test/validator.spec.js
index 147dea0..5b05642 100644
--- a/test/validator.spec.js
+++ b/test/validator.spec.js
@@ -110,18 +110,18 @@ describe("Test resolveMessage", () => {
 	const v = new Validator();
 
 	it("should resolve variables in message string", () => {
-		let res = v.resolveMessage({ type: "stringLength", field: "age", expected: 3, actual: 6 }, v.messages["stringLength"] );
+		let res = v.resolveMessage({ type: "stringLength", field: "age", expected: 3, actual: 6 });
 		expect(res).toBe("The 'age' field length must be 3 characters long!");
 	});
 
 	it("should resolve 0 value in message string", () => {
-		let res = v.resolveMessage({ type: "numberNotEqual", field: "b", expected: 0, actual: 0 }, v.messages["numberNotEqual"] );
+		let res = v.resolveMessage({ type: "numberNotEqual", field: "b", expected: 0, actual: 0 });
 		expect(res).toBe("The 'b' field can't be equal with 0!");
 	});
 
 	it("should resolve more variables in message string", () => {
 		v.messages.custom = "Field {field} and again {field}. Expected: {expected}, actual: {actual}.";
-		let res = v.resolveMessage({ type: "custom", field: "country", expected: "London", actual: 350 },  v.messages.custom );
+		let res = v.resolveMessage({ type: "custom", field: "country", expected: "London", actual: 350 });
 		expect(res).toBe("Field country and again country. Expected: London, actual: 350.");
 	});
 
@@ -354,7 +354,7 @@ describe("Test compile (integration test)", () => {
 
 		it("when schema is defined as an object, and custom path is specified, it should be forwarded to validators", () => {
 			// Note: as the item we validate always must be an object, there is no use
-			// of specifying a custom parent, like for the schema-as-array above.
+			// of specifying a custom parent, like for the schema-as-array above. 
 			// The parent is currently used in the validator code (only forwarded to the generated
 			// function that validates all properties) and there is no way to test it.
 			const v = new Validator();
@@ -687,19 +687,19 @@ describe("Test multiple rules with objects", () => {
 
 	let schema = {
 		list: [
-			{
+			{ 
 				type: "object",
 				props: {
 					name: {type: "string"},
 					age: {type: "number"},
-				}
+				} 
 			},
-			{
+			{ 
 				type: "object",
 				props: {
 					country: {type: "string"},
 					code: {type: "string"},
-				}
+				} 
 			}
 		]
 	};
@@ -768,19 +768,19 @@ describe("Test multiple rules with objects within array", () => {
 		list: {
 			type: "array",
 			items: [
-				{
+				{ 
 					type: "object",
 					props: {
 						name: {type: "string"},
 						age: {type: "number"},
-					}
+					} 
 				},
-				{
+				{ 
 					type: "object",
 					props: {
 						country: {type: "string"},
 						code: {type: "string"},
-					}
+					} 
 				}
 			]
 		}
@@ -907,9 +907,9 @@ describe("Test multiple rules with mixed types", () => {
 		expect(res).toBeInstanceOf(Array);
 		expect(res.length).toBe(2);
 		expect(res[0].type).toBe("string");
-		expect(res[0].field).toBe("value");
+		expect(res[0].field).toBe("value");		
 		expect(res[1].type).toBe("boolean");
-		expect(res[1].field).toBe("value");
+		expect(res[1].field).toBe("value");		
 	});
 
 	it("should give error if 'undefined'", () => {
@@ -919,9 +919,9 @@ describe("Test multiple rules with mixed types", () => {
 		expect(res).toBeInstanceOf(Array);
 		expect(res.length).toBe(2);
 		expect(res[0].type).toBe("required");
-		expect(res[0].field).toBe("value");
+		expect(res[0].field).toBe("value");		
 		expect(res[1].type).toBe("required");
-		expect(res[1].field).toBe("value");
+		expect(res[1].field).toBe("value");		
 	});
 
 });
@@ -931,13 +931,13 @@ describe("Test multiple rules with arrays", () => {
 
 	let schema = {
 		list: [
-			{
+			{ 
 				type: "array",
-				items: "string"
+				items: "string" 
 			},
-			{
+			{ 
 				type: "array",
-				items: "number"
+				items: "number" 
 			}
 		]
 	};
@@ -994,13 +994,13 @@ describe("Test multiple array in root", () => {
 	const v = new Validator();
 
 	let schema = [
-		{
+		{ 
 			type: "array",
-			items: "string"
+			items: "string" 
 		},
-		{
+		{ 
 			type: "array",
-			items: "number"
+			items: "number" 
 		}
 	];
 
@@ -1209,60 +1209,3 @@ describe("Test irregular object property names", () => {
 		expect(res).toBe(true);
 	});
 });
-
-describe("Test $$strict schema restriction on root-level", () => {
-	const v = new Validator();
-
-	let schema = {
-		name: "string",
-		$$strict: true
-	};
-
-	let check = v.compile(schema);
-
-	it("should give error if the object contains additional properties on the root-level", () => {
-		let obj = {
-			name: "test",
-			additionalProperty: "additional"
-		};
-
-		let res = check(obj);
-
-		expect(res).toBeInstanceOf(Array);
-		expect(res.length).toBe(1);
-		expect(res[0].field).toBe("rootObject");
-		expect(res[0].type).toBe("objectStrict");
-	});
-});
-
-describe("Test $$strict schema restriction on sub-level", () => {
-	const v = new Validator();
-
-	let schema = {
-		address: {
-			type: "object",
-			props: {
-				street: "string",
-				$$strict: true
-			}
-		}
-	};
-
-	let check = v.compile(schema);
-
-	it("should give error if the object contains additional properties on the sub-level", () => {
-		let obj = {
-			address: {
-				street: "test",
-				additionalProperty: "additional"
-			}
-		};
-
-		let res = check(obj);
-
-		expect(res).toBeInstanceOf(Array);
-		expect(res.length).toBe(1);
-		expect(res[0].field).toBe("address");
-		expect(res[0].type).toBe("objectStrict");
-	});
-});