Add additional boolean operand parsing in utils.js
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update expands the `parseBooleanOperand` function to handle more string representations of boolean values, including '1', '0', 'on', 'off', 'y', and 'n'. This enhancement improves the flexibility and robustness of boolean parsing in the application.
This commit is contained in:
parent
05d0cd539c
commit
fcdd76f891
@ -87,6 +87,15 @@ function parseBooleanOperand(value) {
|
|||||||
const lower = String(value).trim().toLowerCase();
|
const lower = String(value).trim().toLowerCase();
|
||||||
if (lower === 'yes') return true;
|
if (lower === 'yes') return true;
|
||||||
if (lower === 'no') return false;
|
if (lower === 'no') return false;
|
||||||
|
if (lower === 'true') return true;
|
||||||
|
if (lower === 'false') return false;
|
||||||
|
if (lower === '1') return true;
|
||||||
|
if (lower === '0') return false;
|
||||||
|
if (lower === 'on') return true;
|
||||||
|
if (lower === 'off') return false;
|
||||||
|
if (lower === 'y') return true;
|
||||||
|
if (lower === 'n') return false;
|
||||||
|
if (typeof value === 'boolean') return value;
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user