Closed rostamiani closed 6 years ago
After debugging I found the line of the error. But cannot solve it This is the first lines of main.js from npm package
! function (e, t) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : e.indicative = t()
}(this, function () {
"use strict";
function e(e, t) {
if (! function (e) {
return null !== e && "object" == typeof e
}(e) || "string" != typeof t) return e;
for (var r = t.split("."), n = 0; n < r.length; n++) {
var o = r[n];
if (null === (e = e.hasOwnProperty(o) ? e[o] : null)) break // <------------ This is the error line
}
return e
}
...
After putting a breakpoint there, I found out that the line is executed three times. This is the first and second time:
argument:Array(0) []
field:"phone_number"
validation:"required"
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}
And the last time 'e' is my field list and does not have hasOwnProperty. this is the last time 'e':
Object {username: "yazdan", company_id: "1", first_name: "احمد", last_name: "یزدی", mobile_number: "", …}
address:""
company_id:"1"
date_birth:"1212-12-12"
first_name:"احمد"
id:"5"
last_name:"یزدی"
mobile_number:""
password:""
phone_number:""
type:"0"
username:"yazdan"
Solved
In real world field list was comming from res.body in Express middleware. The res.body is not a standard javascript object and does not have 'hasOwnProperty' method. A solution is this:
I have the same problem. @thetutlage, is there any way to fix it? I am not using AdonisJS. Thanks!
I am having the same issue right now, is there any fix?
Please, create a new issue with a proper way to reproduce your issue.
Package version
5.0.8
Node.js and npm version
10.8.0, 6.2.0
Sample Code (to reproduce the issue)
The validation error:
[{"message":"e.hasOwnProperty is not a function","field":"phone_number","validation":"ENGINE_EXCEPTION"}]