Validate not working as expected on piped functions
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 278
- PR merge metrics
- No merged PRs in 30d
Description
When you use some commands chained with pipe second command's validate function is triggered by it doesn't reject execution.
Here's example:
```
lorem 5 -u paragraphs | note insert or update
Error with code 23502 happened
Message: null value in column "scientist_id" violates not-null constraint
Details: Failing row contains (null, null, ...).
```
This script should generate lorem ipsum text and then insert or update row in database.
But command `note insert or update` require two options (ids) and their validation really work:
```
$ note insert or update
scientist id should present and be number
$ note insert or update -s 1
object id should present and be number
```
But it behave differently when input is piped from another command.
This is how my validation function looks:
```javascript
function validateNoteParams(args){
if(typeof args.options.scientist != 'number'){
return '\tscientist id should present and be number';
}
if(typeof args.options.object != 'number'){
return '\tobject id should present and be number';
}
return true;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.