node-modules/parameter

希望增加 global option matches: true || false, 用来控制是否强制匹配属性,生成Error报错或者自动删除Rule里不存在的属性

17Damon opened this issue · 3 comments

example:
const rule = {
  username: 'string',
  token: 'string',
  role: 'string',
  attributes: 'object',
  offset: {
      delete: true,
  },
  count: 'int',
};
let params = {
  username: 'username',
  token: 'token',
  role: 'role',
  attributes: 'attributes',
  offset: 'offset',
  count: 'count',
  count1: 'count1',
}
console.log(validate(rule, params));
console.log(delete(rule, params));
out:
false || Error();
{
  username: 'username',
  token: 'token',
  role: 'role',
  attributes: 'attributes',
  count: 'count',
};

我可以提供代码。

自动删除Rule里不存在的属性,这个比较符合逻辑。

现在 改用Joi 了 @_@!