Fix: return value of validate
is not type checked.
This commit is contained in:
parent
e4f209bafd
commit
55b42749d6
2 changed files with 8 additions and 9 deletions
15
README.md
15
README.md
|
@ -350,14 +350,7 @@ If the user input empty text (i.e. pressed an Enter key only), return this.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
answer = readlineSync.question('Do you want to install this? :',
|
lang = readlineSync.question('Which language? :', {defaultInput: 'javascript'});
|
||||||
{defaultInput: 'y'});
|
|
||||||
if (answer === 'y') {
|
|
||||||
// install
|
|
||||||
} else {
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
// ** But `keyInYN` method should be used instead of this. **
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### `trueValue`, `falseValue`
|
### `trueValue`, `falseValue`
|
||||||
|
@ -677,6 +670,12 @@ And the following additional options are available.
|
||||||
A string as the characters that can be included in the password. For example, if `'abc123'` is specified, the passwords that include any character other than these 6 characters are refused.
|
A string as the characters that can be included in the password. For example, if `'abc123'` is specified, the passwords that include any character other than these 6 characters are refused.
|
||||||
The [placeholders](#placeholders) like `'${a-e}'` are replaced to the characters like `'abcde'`.
|
The [placeholders](#placeholders) like `'${a-e}'` are replaced to the characters like `'abcde'`.
|
||||||
|
|
||||||
|
For example, let the user input a password that is created with alphabet and some symbols:
|
||||||
|
|
||||||
|
```js
|
||||||
|
password = readlineSync.questionNewPassword('PASSWORD :', {charlist: '${a-z}#$@%'});
|
||||||
|
```
|
||||||
|
|
||||||
##### `min`, `max`
|
##### `min`, `max`
|
||||||
|
|
||||||
*Type:* number
|
*Type:* number
|
||||||
|
|
|
@ -995,7 +995,7 @@ exports.questionPath = function(query, options) {
|
||||||
}
|
}
|
||||||
if (typeof options.validate === 'function' &&
|
if (typeof options.validate === 'function' &&
|
||||||
(res = options.validate(validPath)) !== true) {
|
(res = options.validate(validPath)) !== true) {
|
||||||
error = res + '';
|
if (typeof res === 'string') { error = res; }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue