在Node.js RESTapi中验证用户的输入似乎非常简单Joi
.
但问题是我的应用程序不是用英文写的.这意味着我需要向前端用户发送自定义书面消息.
我搜索了这个,只发现了问题.
也许有人可以为此提供解决方案?
这是我用来验证Joi
系统的代码:
var schema = Joi.object().keys({
firstName: Joi.string().min(5).max(10).required(),
lastName: Joi.string().min(5).max(10).required()
..
});
Joi.validate(req.body, schema, function(err, value) {
if (err) {
return catched(err.details);
}
});
function catched(reject) {
res.json({
validData: false,
errors: reject
});
}
Run Code Online (Sandbox Code Playgroud)
另外,有没有办法Joi
在客户端使用?
谢谢!
是时候在 StackOverflow 中提问了,因为我发现了不止一个 excel 库,有些基于客户端,有些基于服务器端。
第一的
我正在使用 Node.js,在哪里首选使用 Excel 库,客户端还是服务器端?
第二
您了解并信任哪一个优秀的 Excel 库?我尝试安装这个: https: //github.com/natergj/excel4node 但不幸的是它在 CLI 中抛出下一个错误:
module.js:544
throw err;
^
Error: Cannot find module 'excel4node'
at Function.Module._resolveFilename (module.js:542:15)
at Function.Module._load (module.js:472:25)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/razbuchnik/node/app.js:11:10)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
[nodemon] app crashed - waiting for file changes before starting...
Run Code Online (Sandbox Code Playgroud)
这里有什么好的建议吗?
谢谢。