option flatten behaves unreasonable
Closed this issue · 3 comments
molinjun commented
Hi:
when I wrote a middleware to handle the error, I passed a option 'flatten', then I got an unexpected result. I read the code, and maybe that is the problem.
The origin code:
ValidationError.prototype.toJSON = function () {
if (this.flatten) return flatten(map(this.errors, 'messages'));
return {
status: this.status,
statusText: this.statusText,
errors: this.errors
};
};
or mybe it should be:
ValidationError.prototype.toJSON = function toJSON() {
return {
status: this.status,
statusText: this.statusText,
errors: this.flatten ? flatten(map(this.errors, 'messages')) : this.errors
};
};
Not sure if it is a bug, waiting for ur answer, thx!
colthreepv commented
Indeed, you seem correct
molinjun commented
@colthreepv ok,waitting for ur fix (^ _ ^)
colthreepv commented
Fixed