Joi 小记

Joi 是 node 的验证模块。github 地址:https://github.com/hapijs/joi

  1. 允许通过多余的字段
Joi.validate(obj, schema, {allowUnknown: true}); // pass, 配置 {allowUnknown: true}
  1. Joi 的 base64 检测不能包含前缀标识
Joi.string().base64

// error
"data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="

// right
"R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="