检查声明性JavaScript对象验证。
用法:
var checky = require('checky');
var checkPerson = checky({
name: String,
age: { type: Number, min: 18, max: 80 },
hobby: ['Running', 'Gaming', 'Hacking'],
other: { type: String, optional: true }
});
var dennis = { name: 'Dennis Ritchie', age: 70, hobby: 'Hacking' };
checkPerson(dennis);
暂无评论