json-schema-validation
v0.0.3
Published
validation for json-schema
Downloads
13
Readme
json-schema-validation
json-schema 校验工具
安装
npm install json-schema-validation --save
使用
var validator = require( 'json-schema-validation' );
validator( [ 1, 3, ], { type: 'object' }, function( err, result ){
console.log( result );
/* -->
error: Object
errorType: "INVALID_TYPE"
message: "Error: [INVALID_TYPE] invalid type: array (expected object) at data path: 'ROOT', by schema at path: '/type';"
result: false
*/
});
$ref
如果schema中包含 $ref
会先使用json-schema-ref模块进行解析(所以这个校验工具是个异步模块);