🚸 improve data type validation
This commit is contained in:
parent
860a58bbc2
commit
a8022312dd
@ -33,7 +33,7 @@ Juicescript.command_define({
|
||||
let data_type = runner.data_type(add);
|
||||
if(data_type !== Juicescript.data_type.NUM && data_type !== Juicescript.data_type.STR){
|
||||
// ignore with warning
|
||||
runner.warning_argument(q, "invalid data type " + Juicescript.data_type.name(data_type));
|
||||
runner.warning_argument(q, "expected data type NUM or STR, but got " + Juicescript.data_type.name(data_type));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ Juicescript.command_define({
|
||||
let data_type = runner.data_type(devide);
|
||||
if(data_type !== Juicescript.data_type.NUM){
|
||||
// ignore with warning
|
||||
runner.warning_argument(q, "invalid data type " + Juicescript.data_type.name(data_type));
|
||||
runner.warning_argument(q, "expected data type NUM, but got " + Juicescript.data_type.name(data_type));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,14 @@ Juicescript.command_define({
|
||||
// flag name
|
||||
let flag = runner.argument_value(1);
|
||||
|
||||
// validate data type
|
||||
let data_type = runner.data_type(flag);
|
||||
if(data_type !== Juicescript.data_type.STR){
|
||||
// ignore with warning
|
||||
runner.warning_argument(1, "expected data type STR, but got " + Juicescript.data_type.name(data_type));
|
||||
return;
|
||||
}
|
||||
|
||||
// load this scope's flag list
|
||||
let flag_list = runner.scope_tree.flag;
|
||||
|
||||
|
@ -35,7 +35,7 @@ Juicescript.command_define({
|
||||
let factor_data_type = runner.data_type(factor);
|
||||
if(factor_data_type !== Juicescript.data_type.NUM){
|
||||
// ignore with warning
|
||||
runner.warning_argument(q, "invalid data type " + Juicescript.data_type.name(factor_data_type));
|
||||
runner.warning_argument(q, "expected data type NUM, but got " + Juicescript.data_type.name(factor_data_type));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ Juicescript.command_define({
|
||||
let data_type = runner.data_type(subtract);
|
||||
if(data_type !== Juicescript.data_type.NUM){
|
||||
// ignore with warning
|
||||
runner.warning_argument(q, "invalid data type " + Juicescript.data_type.name(data_type));
|
||||
runner.warning_argument(q, "expected data type NUM, but got " + Juicescript.data_type.name(data_type));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user