Node.js提示模块不遵守选项
问题描述:
我有一个相对简单的node.js代码块,这是我第一次尝试使用提示模块。看看:Node.js提示模块不遵守选项
const schema = {
properties : {
username : {
description : "Please enter username", type : "string", required : true,
validator: /^[a-zA-Z0-9]+$/, warning : "must be comprised of letters and numbers only"
}
}
};
prompt.start();
prompt.get(schema, function (inError, inResult) {
if (!inError) {
userInfo.username = inResult.username;
}
});
看,不要太强悍。问题是,当我运行它时,输出是这样的:
“用户名:”
...而应该是这样......
“请输入用户名:”
这不是表达我的描述选项,我正在试图找出原因的桌子上。这可能是我的一些愚蠢的程序员技巧,但我只是没有看到它。我试过只是传递属性本身,而不是作为外部模式对象的一部分,但这没有什么区别。更糟糕的是它似乎在履行验证程序,所以它看起来可能是一个错误?
任何人有任何想法?谢谢!
答
您应该用message
替换description
。这不是记录的变化。
username : {
message : "Please enter username", type : "string", required : true,
validator: /^[a-zA-Z0-9]+$/, warning : "must be comprised of letters and numbers only"
}
完美,谢谢!永远快乐,当它不是我自己愚蠢的错误:) –