nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: icebob/fastest-validator
Pull request #128 (2020-04-16 11:55:38)

deep-extend: fix object type checking bug
`typeof o === "object"` doesn't always return expected result (e.g: with array, null, regexp, ....).



Patch:
diff --git a/lib/helpers/deep-extend.js b/lib/helpers/deep-extend.js
index cb03fc7..2a313ea 100644
--- a/lib/helpers/deep-extend.js
+++ b/lib/helpers/deep-extend.js
@@ -1,12 +1,17 @@
 "use strict";
 
+function isObjectHasKeys(v) {
+	if (typeof v !== "object" || v == null) return false;
+	return Object.keys(v).length > 0;
+}
+
 function deepExtend(destination, source, options = {}) {
 	for (let property in source) {
-		if (typeof source[property] === "object" && source[property] !== null) {
+		if (isObjectHasKeys(source[property])) {
 			destination[property] = destination[property] || {};
 			deepExtend(destination[property], source[property], options);
 		} else {
-			if (options.skipIfExist === true && destination[property] !== undefined ) continue;
+			if (options.skipIfExist === true && destination[property] !== undefined) continue;
 			destination[property] = source[property];
 		}
 	}


Test patch:
diff --git a/test/helpers/deep-extend.spec.js b/test/helpers/deep-extend.spec.js
index 8bb3a12..66f82eb 100644
--- a/test/helpers/deep-extend.spec.js
+++ b/test/helpers/deep-extend.spec.js
@@ -10,7 +10,7 @@ describe("deepExtend", () => {
 			},
 			d: true,
 			j: [],
-			k: [1,2]
+			k: [1,2],
 		}, {
 			a: {
 				b: 10,
@@ -21,7 +21,8 @@ describe("deepExtend", () => {
 				h: "H"
 			},
 			j: "some",
-			k: [5,6]
+			k: [5,6],
+			r: /s/
 		});
 		expect(result).toEqual({
 			a: {
@@ -35,7 +36,8 @@ describe("deepExtend", () => {
 				h: "H"
 			},
 			j: "some",
-			k: [5,6]
+			k: [5,6],
+			r: /s/
 		});
 	});
 });
Repository: icebob/fastest-validator
Pull request #131 (2020-04-27 11:02:38)

Fix deep-extend bug with arrays
#130 
The easiest way that comes to mind


Patch:
diff --git a/index.d.ts b/index.d.ts
index 5ab65c9..ea55be1 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -786,7 +786,7 @@ declare module 'fastest-validator' {
 
 	type CheckerFunction<T = unknown> = (value: T, schema: ValidationSchema, path: string, parent: object | null, context: Context) => true | ValidationError[];
 
-	type CompilationFunction = (this: Validator, rule: CompilationRule, path: string, context: Context) => { sanitized?: boolean, source: string };
+	type CompilationFunction = (rule: CompilationRule, path: string, context: Context) => { sanitized?: boolean, source: string };
 
 	class Validator {
 		/**
diff --git a/lib/helpers/deep-extend.js b/lib/helpers/deep-extend.js
index 2a313ea..7507734 100644
--- a/lib/helpers/deep-extend.js
+++ b/lib/helpers/deep-extend.js
@@ -1,7 +1,7 @@
 "use strict";
 
 function isObjectHasKeys(v) {
-	if (typeof v !== "object" || v == null) return false;
+	if (typeof v !== "object" || Array.isArray(v) || v == null) return false;
 	return Object.keys(v).length > 0;
 }
 


Test patch:
diff --git a/test/helpers/deep-extend.spec.js b/test/helpers/deep-extend.spec.js
index 66f82eb..254e6bc 100644
--- a/test/helpers/deep-extend.spec.js
+++ b/test/helpers/deep-extend.spec.js
@@ -22,7 +22,9 @@ describe("deepExtend", () => {
 			},
 			j: "some",
 			k: [5,6],
-			r: /s/
+			l: [1,2],
+			r: /s/,
+			o: {}
 		});
 		expect(result).toEqual({
 			a: {
@@ -37,7 +39,9 @@ describe("deepExtend", () => {
 			},
 			j: "some",
 			k: [5,6],
-			r: /s/
+			l: [1,2],
+			r: /s/,
+			o: {}
 		});
 	});
 });
Repository: icebob/fastest-validator
Pull request #160 (2020-06-15 21:51:36)

BugFix: checker function must be called after rule
#155 



Patch:
diff --git a/lib/validator.js b/lib/validator.js
index b281ff2..73d8696 100644
--- a/lib/validator.js
+++ b/lib/validator.js
@@ -235,8 +235,9 @@ class Validator {
 				res.source = res.source.replace(/%%INDEX%%/g, rule.index);
 				const fn = new Function("value", "field", "parent", "errors", "context", res.source);
 				context.fn[rule.index] = fn;
-				sourceCode.push(this.makeCustomValidator({vName: resVar, path: customPath, schema: rule.schema, context, messages: rule.messages, ruleIndex: rule.index}));
 				sourceCode.push(this.wrapRequiredCheckSourceCode(rule, innerSrc.replace(/%%INDEX%%/g, rule.index), resVar));
+				sourceCode.push(this.makeCustomValidator({vName: resVar, path: customPath, schema: rule.schema, context, messages: rule.messages, ruleIndex: rule.index}));
+
 			} else {
 				sourceCode.push(this.wrapRequiredCheckSourceCode(rule));
 			}


Test patch:
diff --git a/test/rules/multi.spec.js b/test/rules/multi.spec.js
index e1ce797..1979dc4 100644
--- a/test/rules/multi.spec.js
+++ b/test/rules/multi.spec.js
@@ -2,7 +2,7 @@
 
 const Validator = require("../../lib/validator");
 const v = new Validator({
-	useNewCustomCheckerFunction: true
+	useNewCustomCheckerFunction: true,
 });
 
 describe("Test rule: multi", () => {
@@ -28,7 +28,7 @@ describe("Test rule: multi", () => {
 		expect(fn).toBeCalledWith("s", [], schema.rules[0], "$$root", null, expect.any(Object));
 	});
 
-	it("should value equals to other field", () => {
-		// TODO: move from validator.spec.js
-	});
+	// it("should value equals to other field", () => {
+	// 	// TODO: move from validator.spec.js
+	// });
 });
diff --git a/test/validator.spec.js b/test/validator.spec.js
index 880f1f5..90c5062 100644
--- a/test/validator.spec.js
+++ b/test/validator.spec.js
@@ -428,7 +428,7 @@ describe("Test custom validation v1", () => {
 	});
 });
 
-describe("Test custom validation v2", () => {
+describe("Test custom validation", () => {
 	const v = new Validator({
 		useNewCustomCheckerFunction: true,
 		messages: {
@@ -468,6 +468,25 @@ describe("Test custom validation v2", () => {
 		expect(check({num: 18})[0].type).toEqual("numberMax");
 		expect(check({num: 13})[0].type).toEqual("evenNumber");
 	});
+
+	it("should call checker function after build-in rule", () => {
+		// depended to number rule
+		const checkerFn = jest.fn((v) => v);
+
+		const schema = {
+			a: {
+				type: "number",
+				convert: true,
+				custom: checkerFn
+			}
+		};
+		const check = v.compile(schema);
+		const o = { a: "123" };
+
+		expect(check(o)).toBe(true);
+		expect(checkerFn).toBeCalledTimes(1);
+		expect(checkerFn.mock.calls[0][0]).toBe(123);
+	});
 });
 
 describe("Test default settings", () => {
Repository: icebob/fastest-validator
Pull request #163 (2020-06-16 11:48:22)

Add aliases and customRules in Validator constructor 
#162 


Patch:
diff --git a/index.d.ts b/index.d.ts
index 4e061bf..c8ec553 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -813,6 +813,20 @@ declare module "fastest-validator" {
 		defaults?: {
 			[key in ValidationRuleName]: ValidationSchema;
 		};
+
+		/**
+	 	 * For set aliases
+	 	 */
+		aliases?: {
+			[key: string]: ValidationRuleObject
+		}
+
+		/**
+	 	 * For set custom rules.
+	 	 */
+		customRules?: {
+			[key: string]: CompilationFunction
+		}
 	}
 
 	export interface CompilationRule {
@@ -894,11 +908,11 @@ declare module "fastest-validator" {
 		add(type: string, fn: CompilationFunction): void;
 
 		/**
-		 * Register a custom validation rule in validation object
+		 * Register an alias in validation object
 		 * @param {string} name
-		 * @param validationRule
+		 * @param {ValidationRuleObject} validationRule
 		 */
-		alias(name: string, validationRule: ValidationRule): void;
+		alias(name: string, validationRule: ValidationRuleObject): void;
 
 		/**
 		 * Build error message
diff --git a/lib/validator.js b/lib/validator.js
index 73d8696..840b3c7 100644
--- a/lib/validator.js
+++ b/lib/validator.js
@@ -44,19 +44,23 @@ class Validator {
 			messages: deepExtend({}, defaultMessages)
 		};
 		this.defaults = {};
+		this.messages = this.opts.messages;
+		this.rules = loadRules();
+		this.aliases = {};
+		this.cache = new Map();
 
 		if (opts) {
 			deepExtend(this.opts, opts);
 			if (opts.defaults) deepExtend(this.defaults, opts.defaults);
-			// eslint-disable-next-line no-console
-		}
 
-		this.messages = this.opts.messages;
+			if (opts.aliases) {
+				for (const aliasName in opts.aliases) this.alias(aliasName, opts.aliases[aliasName]);
+			}
 
-		// Load rules
-		this.rules = loadRules();
-		this.aliases = {};
-		this.cache = new Map();
+			if (opts.customRules) {
+				for (const ruleName in opts.customRules) this.add(ruleName, opts.customRules[ruleName]);
+			}
+		}
 	}
 
 	/**


Test patch:
diff --git a/test/validator.spec.js b/test/validator.spec.js
index 90c5062..112036b 100644
--- a/test/validator.spec.js
+++ b/test/validator.spec.js
@@ -49,6 +49,37 @@ describe("Test constructor", () => {
 		expect(v2.messages.numberMax).toBe("The '{field}' field must be less than or equal to {expected}.");
 	});
 
+	it("should set aliases", () => {
+		const aliases = {
+			a: { type: "string" },
+			b: { type: "string" }
+		};
+
+		const v = new Validator({
+			aliases
+		});
+
+		expect(v.aliases).toBeInstanceOf(Object);
+		expect(v.aliases.a).toEqual(aliases.a);
+		expect(v.aliases.b).toEqual(aliases.b);
+
+	});
+
+	it("should set customRules", () => {
+		const customRules = {
+			a: () => "",
+			b: () => ""
+		};
+
+		const v = new Validator({
+			customRules
+		});
+
+		expect(v.rules).toBeInstanceOf(Object);
+		expect(v.rules.a).toEqual(customRules.a);
+		expect(v.rules.b).toEqual(customRules.b);
+	});
+
 });
 
 describe("Test validate", () => {
Repository: icebob/fastest-validator
Pull request #176 (2020-07-06 12:06:15)

Fix/uppercase UUID
We were encountering an issue with uppercase v4 UUIDs not validating, it was due to a check using the original uppercased `value` instead of the normalised (lowercased) `val`.

A test has been added for case insensitive UUIDs of any version. 


Patch:
diff --git a/lib/rules/uuid.js b/lib/rules/uuid.js
index 3ead1d0..5bbe145 100644
--- a/lib/rules/uuid.js
+++ b/lib/rules/uuid.js
@@ -38,7 +38,7 @@ module.exports = function({ schema, messages }, path) {
 		case 3:
 		case 4:
 		case 5:
-			if (["8", "9", "a", "b"].indexOf(value.charAt(19)) === -1) {
+			if (["8", "9", "a", "b"].indexOf(val.charAt(19)) === -1) {
 				${this.makeError({ type: "uuid",  actual: "value", messages })}
 			}
 		}


Test patch:
diff --git a/test/rules/uuid.spec.js b/test/rules/uuid.spec.js
index b04416c..feb585d 100644
--- a/test/rules/uuid.spec.js
+++ b/test/rules/uuid.spec.js
@@ -60,4 +60,24 @@ describe("Test rule: uuid", () => {
 		expect(check5("fdda765f-fc57-5604-a269-52a7df8164ec")).toEqual(true);
 
 	});
+
+	it("should not be case insensitive", () => {
+		const check1 = v.compile({ $$root: true, type: "uuid", version: 1 });
+		const check2 = v.compile({ $$root: true, type: "uuid", version: 2 });
+		const check3 = v.compile({ $$root: true, type: "uuid", version: 3 });
+		const check4 = v.compile({ $$root: true, type: "uuid", version: 4 });
+		const check5 = v.compile({ $$root: true, type: "uuid", version: 5 });
+
+		expect(check1("45745c60-7b1a-11e8-9c9c-2d42b21b1a3e")).toEqual(true);
+		expect(check2("9a7b330a-a736-21e5-af7f-feaf819cdc9f")).toEqual(true);
+		expect(check3("9125a8dc-52ee-365b-a5aa-81b0b3681cf6")).toEqual(true);
+		expect(check4("10ba038e-48da-487b-96e8-8d3b99b6d18a")).toEqual(true);
+		expect(check5("fdda765f-fc57-5604-a269-52a7df8164ec")).toEqual(true);
+		
+		expect(check1("45745C60-7B1A-11E8-9C9C-2D42B21B1A3E")).toEqual(true);
+		expect(check2("9A7B330A-A736-21E5-AF7F-FEAF819CDC9F")).toEqual(true);
+		expect(check3("9125A8DC-52EE-365B-A5AA-81B0B3681CF6")).toEqual(true);
+		expect(check4("10BA038E-48DA-487B-96E8-8D3B99B6D18A")).toEqual(true);
+		expect(check5("FDDA765F-FC57-5604-A269-52A7DF8164EC")).toEqual(true);
+	});
 });
Repository: icebob/fastest-validator
Pull request #183 (2020-08-10 21:55:39)

[BugFix] [objectID rule] validator throws error when convert: true


Patch:
diff --git a/lib/rules/objectID.js b/lib/rules/objectID.js
index 1d463a3..36df94e 100644
--- a/lib/rules/objectID.js
+++ b/lib/rules/objectID.js
@@ -12,6 +12,7 @@ module.exports = function({ schema, messages, index }, path, context) {
 		const ObjectID = context.customs[${index}].schema.ObjectID;
 		if (!ObjectID.isValid(value)) {
 			${this.makeError({ type: "objectID", actual: "value", messages })}
+			return;
 		}
 
 		${schema.convert ? "return new ObjectID(value)" : "return value;" } ;


Test patch:
diff --git a/test/rules/objectID.spec.js b/test/rules/objectID.spec.js
index e575e72..764c4e8 100644
--- a/test/rules/objectID.spec.js
+++ b/test/rules/objectID.spec.js
@@ -27,4 +27,13 @@ describe("Test rule: objectID", () => {
 		expect(o.id).toBeInstanceOf(ObjectID);
 		expect(o.id).toEqual(oid);
 	});
+
+	it("should catch hexString problems when convert: true", () => {
+		const message = "The 'id' field must be an valid ObjectID";
+		const check = v.compile({ id: { type: "objectID", ObjectID, convert: true } });
+
+		const badID = "5f082780b00cc7401fb8";
+		const o = { id: badID };
+		expect(check(o)).toEqual([{ type: "objectID", field: "id", actual: badID, message }]);
+	});
 });
Repository: icebob/fastest-validator
Pull request #203 (2020-11-22 21:28:04)

(Bugfix) multiple custom validator bug #202
#202


Patch:
diff --git a/lib/validator.js b/lib/validator.js
index 93f116c..a0ca2fa 100644
--- a/lib/validator.js
+++ b/lib/validator.js
@@ -419,11 +419,12 @@ class Validator {
 				`;
 			}
 
+			const result = "res_" + ruleVName;
 			return `
 				const ${ruleVName} = context.customs[${ruleIndex}];
-				const res = ${ruleVName}.schema.${fnName}.call(this, ${vName}, ${ruleVName}.schema, "${path}", parent, context);
-				if (Array.isArray(res)) {
-					res.forEach(err => errors.push(Object.assign({ message: ${ruleVName}.messages[err.type], field }, err)));
+				const ${result} = ${ruleVName}.schema.${fnName}.call(this, ${vName}, ${ruleVName}.schema, "${path}", parent, context);
+				if (Array.isArray(${result})) {
+					${result}.forEach(err => errors.push(Object.assign({ message: ${ruleVName}.messages[err.type], field }, err)));
 				}
 		`;
 		}


Test patch:
diff --git a/test/validator.spec.js b/test/validator.spec.js
index 48a5245..a9ebb32 100644
--- a/test/validator.spec.js
+++ b/test/validator.spec.js
@@ -444,13 +444,9 @@ describe("Test custom validation v1", () => {
 		}
 	});
 
-	let check;
-	const fn = jest.fn();
-
-
 	it("should compile without error", () => {
-
-		check = v.compile({
+		const fn = jest.fn();
+		const check = v.compile({
 			num: {
 				type: "number",
 				min: 10,
@@ -467,6 +463,20 @@ describe("Test custom validation v1", () => {
 	});
 
 	it("should work correctly with custom validator", () => {
+		const fn = jest.fn();
+		const check = v.compile({
+			num: {
+				type: "number",
+				min: 10,
+				max: 15,
+				integer: true,
+				custom(value){
+					fn(value);
+					if (value % 2 !== 0) return [{ type: "evenNumber", actual: value }];
+				}
+			}
+		});
+
 		const res = check({num: 12});
 		expect(res).toBe(true);
 		expect(fn).toBeCalledWith(12);
@@ -475,6 +485,31 @@ describe("Test custom validation v1", () => {
 		expect(check({num: 18})[0].type).toEqual("numberMax");
 		expect(check({num: 13})[0].type).toEqual("evenNumber");
 	});
+
+	it("should work with multiple custom validators", () => {
+		const fn = jest.fn();
+
+		const check = v.compile({
+			a: {
+				type: "number",
+				custom(value){
+					fn(value);
+					if (value % 2 !== 0) return [{ type: "evenNumber", actual: value }];
+				}
+			}, 
+			b: {
+				type: "number",
+				custom(value){
+					fn(value);
+					if (value % 2 !== 0) return [{ type: "evenNumber", actual: value }];
+				}
+			}
+		});
+
+		const res = check({a: 12, b:10});
+		expect(res).toBe(true);
+		expect(fn).toBeCalledTimes(2);
+	});
 });
 
 describe("Test custom validation", () => {
Repository: icebob/fastest-validator
Pull request #222 (2021-03-09 19:34:56)

fix(string): escape pattern toString
Issue #221

intech: ![Снимок экрана от 2021-03-09 22-35-50](https://user-images.githubusercontent.com/451306/110527309-dc05b000-8127-11eb-892d-f0cbcb5892d5.png)
I tested the bug on my computer and passed all tests successfully.
intech: @erfanium what is the best name for it? Or replace the `quote` test?

Patch:
diff --git a/lib/rules/string.js b/lib/rules/string.js
index b52e7bd..164083f 100644
--- a/lib/rules/string.js
+++ b/lib/rules/string.js
@@ -139,7 +139,7 @@ module.exports = function checkString({ schema, messages }, path, context) {
 
 		const patternValidator = `
 			if (!${pattern.toString()}.test(value))
-				${this.makeError({ type: "stringPattern", expected: "\"" + pattern.toString().replace("\"", "\\\"") + "\"", actual: "origValue", messages })}
+				${this.makeError({ type: "stringPattern", expected: `"${pattern.toString().replace(/"/g, "\\$&")}"`, actual: "origValue", messages })}
 		`;
 
 		src.push(`


Test patch:
diff --git a/test/rules/string.spec.js b/test/rules/string.spec.js
index eefa015..df42405 100644
--- a/test/rules/string.spec.js
+++ b/test/rules/string.spec.js
@@ -95,6 +95,13 @@ describe("Test rule: string", () => {
 		expect(check("JOHN")).toEqual(true);
 	});
 
+	it("check escape pattern", () => {
+		const 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 check = v.compile({ $$root: true, type: "string", pattern });
+
+		expect(check("test@test.com")).toEqual([{ field: undefined, type: "stringPattern", expected: "/^(([^<>()[]\.,;:\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,}))$/", actual: "test@test.com", message: "The '' field fails to match the required pattern." }]);
+	});
+
 	it("check contains", () => {
 		const check = v.compile({ $$root: true, type: "string", contains: "bob" });
 
diff --git a/test/typescript/rules/string.spec.ts b/test/typescript/rules/string.spec.ts
index ce0e95b..3e39207 100644
--- a/test/typescript/rules/string.spec.ts
+++ b/test/typescript/rules/string.spec.ts
@@ -97,6 +97,12 @@ describe('TypeScript Definitions', () => {
 			expect(check('JOHN')).toEqual(true);
 		});
 
+		it("check escape pattern", () => {
+			const 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 check = v.compile({ $$root: true, type: "string", pattern });
+			expect(check("test@test.com")).toEqual([{ field: undefined, type: "stringPattern", expected: "/^(([^<>()[]\.,;:\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,}))$/", actual: "test@test.com", message: "The '' field fails to match the required pattern." }]);
+		});
+
 		it('check contains', () => {
             const check = v.compile({ $$root: true, type: 'string', contains: 'bob' });
Repository: icebob/fastest-validator
Pull request #298 (2022-07-11 10:33:02)

fix: issue #297
In the case object's validator found errors:
+ `strict: true` should continuously validate even
+ `strict: remove` will NOT remove the field from object



Patch:
diff --git a/lib/rules/object.js b/lib/rules/object.js
index c963233..b332c4a 100644
--- a/lib/rules/object.js
+++ b/lib/rules/object.js
@@ -69,37 +69,37 @@ module.exports = function ({ schema, messages }, path, context) {
 
 		// Strict handler
 		if (schema.strict) {
-			sourceCode.push(`
-				if (errors.length === 0) {
-			`);
 			const allowedProps = Object.keys(subSchema);
 
 			sourceCode.push(`
-					field = parentField;
-					var invalidProps = [];
-					var props = Object.keys(parentObj);
-
-					for (let i = 0; i < props.length; i++) {
-						if (${JSON.stringify(allowedProps)}.indexOf(props[i]) === -1) {
-							invalidProps.push(props[i]);
-						}
+				field = parentField;
+				var invalidProps = [];
+				var props = Object.keys(parentObj);
+
+				for (let i = 0; i < props.length; i++) {
+					if (${JSON.stringify(allowedProps)}.indexOf(props[i]) === -1) {
+						invalidProps.push(props[i]);
 					}
-					if (invalidProps.length) {
+				}
+				if (invalidProps.length) {
 			`);
-			if (schema.strict == "remove") {
+			if (schema.strict === "remove") {
+				sourceCode.push(`
+					if (errors.length === 0) {
+				`);
 				sourceCode.push(`
 						invalidProps.forEach(function(field) {
 							delete parentObj[field];
 						});
 				`);
+				sourceCode.push(`
+					}
+				`);
 			} else {
 				sourceCode.push(`
 					${this.makeError({ type: "objectStrict", expected: "\"" + allowedProps.join(", ") + "\"", actual: "invalidProps.join(', ')", messages })}
 				`);
 			}
-			sourceCode.push(`
-					}
-			`);
 			sourceCode.push(`
 				}
 			`);


Test patch:
diff --git a/test/rules/multi.spec.js b/test/rules/multi.spec.js
index 53986ff..bb5cef0 100644
--- a/test/rules/multi.spec.js
+++ b/test/rules/multi.spec.js
@@ -87,6 +87,18 @@ describe("Test rule: multi", () => {
 
 			expect(check({d: 4})).toEqual([{"actual": undefined, "field": "a", "message": "The 'a' field is required.", "type": "required"}, {"actual": undefined, "field": "b", "message": "The 'b' field is required.", "type": "required"}, {"actual": undefined, "field": "c", "message": "The 'c' field is required.", "type": "required"}]);
 		});
+
+		it("issue #297", () => {
+			const v = new Validator();
+			const check = v.compile({
+				$$strict: true,
+				age: "number",
+				name: "string",
+				surname: "string",
+			});
+
+			expect(check({ address: "London", age: "22", name: "John", surname: "Doe" })).toEqual([{"type":"number","message":"The 'age' field must be a number.","field":"age","actual":"22"},{"type":"objectStrict","message":"The object '' contains forbidden keys: 'address'.","expected":"age, name, surname","actual":"address"}] );
+		});
 	});
 
 	describe("should work with custom validator", () => {