mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Perform case-insensitive checking when converting booleans from strings
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
558424ecee
commit
8424fb44f6
@ -19,8 +19,8 @@ export const PermissiveBoolean = new t.Type<boolean, t.TypeOf<PermissiveType>>(
|
||||
(m, c) =>
|
||||
permissiveValue.validate(m, c).chain(v => {
|
||||
switch (typeof v) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'boolean':
|
||||
case 'number':
|
||||
const val = checkTruthy(v);
|
||||
if (val == null) {
|
||||
|
@ -61,6 +61,9 @@ export function checkString(s: NullableLiteral): string | void {
|
||||
* which represents if the input was truthy
|
||||
*/
|
||||
export function checkTruthy(v: string | boolean | number): boolean | void {
|
||||
if (_.isString(v)) {
|
||||
v = v.toLowerCase();
|
||||
}
|
||||
switch (v) {
|
||||
case '1':
|
||||
case 'true':
|
||||
|
Loading…
x
Reference in New Issue
Block a user