minLength 不适用于 JSON 架构中的字符串

minLength not working with String in JSON Schema

我是 node 的新手,所以可能是我使用的 JSON 架构不正确,如果我错了请纠正我。

我一直在使用名为 jsonschema 的 npm 模块。

为了使用验证,我正在使用它:

var Validator = require('jsonschema').Validator;
var v = new Validator();
var instance = {
    "user_id"   :   "jesus",
    "password"  :   "password"
};
var schema = {
    "id" : "Login_login",
    "type" : "object",
    "additionalProperties" : false,
    "properties" : {
        "user_id": {
            "type" : "string",
            "required": true,
            "minLenth" : 8,
            "maxLength" : 10,
            "description": "User id to login."
        },
        "password" : {
            "type" : "string",
            "required": true,
            "minLength" : 8,
            "maxLength" : 10,
            "description" : "password to login."
        }
    }
};
var result = v.validate(instance, schema);
console.log('>>>>>> ' + result);

但关键是结果没有错误,尽管 user_idminLength 保持为 8,但是我已经传递了 5 个字符,所以如果我没有错,结果应该会抛出相同的错误,为什么会这样 :(

架构本身需要验证。它的 "user_id" 条件 "minLength" 拼写没有 "g"。