0.0.2 • Published 11 years ago

leach v0.0.2

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

leach Build Status Coverage Status

步骤:

  1. 选出需要的字段
  2. 检查字段的类型是否正确,如果不对,尝试转换为目标类型
  3. 检测值是否符合目标类型
  4. 检测值是否在范围中
  5. 上述条件任意一条不符合,就舍弃该字段。
  6. 得到最终值。

设计思路:

  1. Scheme
  2. 验证方法

使用

Installation

$ npm install leach

Demo

var schema = {
  'hehe': {
    type: 'number',
    check: function (input) {
      return [1, 2, 3, 4].indexOf(input) !== -1;
    }
  }
};
var input = {
  'hehe': '1000'
};
var output = leach(schema, input);

License

The MIT license

0.0.2

11 years ago

0.0.1

11 years ago