如何清理猫鼬验证错误

时间:2015-11-20 19:33:46

标签: node.js mongoose

我正在使用mongoose进行验证,我想将结果传回客户端。 mongoose为错误提供的JSON blob几乎就是我所需要的,但它有一些额外的东西:

errors: 
 { username: 
    { [ValidatorError: Path `username` is required.]
      properties: [Object],
      message: 'Path `username` is required.',
      name: 'ValidatorError',
      kind: 'required',
      path: 'username',
      value: undefined } } }

username.properties字段对于客户来说是不必要的。我知道我可以做delete username.properties,但有没有更好的方法来清理JSON?

1 个答案:

答案 0 :(得分:0)

使用static RestResponse<T> ApiCall<T>(object param1, object param2, ...) RestResponse<T> restResponse = RestClient.Execute<T>(restRequest); return restResponse;

lodash
相关问题