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:
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;
}
When you use some commands chained with pipe second command's validate function is triggered by it doesn't reject execution. Here's example:
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:But it behave differently when input is piped from another command. This is how my validation function looks: