fix jq validation
validation always failed because it was looking for a single char because VALIDATION=. used to be by default
This commit is contained in:
parent
2b24b0fb67
commit
b4faa87700
|
@ -92,12 +92,14 @@ _poll() {
|
|||
|
||||
local failed=0
|
||||
if [ "$JQ_VALIDATION" ];then
|
||||
echo "$NEWVAL" | jq -e "$JQ_VALIDATION" > /dev/null || failed=1
|
||||
echo "$NEWVAL" | jq -e "$JQ_VALIDATION" > /dev/null || failed=2
|
||||
fi
|
||||
if [ "$VALIDATION" ];then
|
||||
echo "$NEWVAL" | grep -qE "$VALIDATION" || failed=1
|
||||
fi
|
||||
if (( failed ));then
|
||||
if (( failed == 2 ));then
|
||||
warn "$NEWVAL failed jq validation"
|
||||
elif (( failed ));then
|
||||
warn "$NEWVAL failed validation"
|
||||
else
|
||||
echo "$NEWVAL"
|
||||
|
@ -123,7 +125,7 @@ filter() {
|
|||
|
||||
# VALIDATORS
|
||||
|
||||
VALIDATION=.
|
||||
VALIDATION=
|
||||
output_integer() {
|
||||
VALIDATION='^-?[0-9]+$'
|
||||
}
|
||||
|
@ -136,6 +138,7 @@ output_string() {
|
|||
VALIDATION="${1-.*}"
|
||||
}
|
||||
|
||||
JQ_VALIDATION=
|
||||
output_json() {
|
||||
JQ_VALIDATION="${1-.}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user