Don't force on/yes/y/off/no/n to booleans for service button (#3858)

- Relax string conversion to boolean as this breaks other use cases.
This commit is contained in:
Joris Pelgröm 2023-09-13 03:51:13 +02:00 committed by GitHub
parent fb1bdc05bb
commit 50a8b9eee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -205,21 +205,9 @@ class WidgetDynamicFieldAdapter(
}
}
private fun String.toBooleanOrNull(): Boolean? {
// Parse all valid YAML boolean values
return when (this.trim().lowercase(Locale.getDefault())) {
"true" -> true
"on" -> true
"yes" -> true
"y" -> true
"false" -> false
"off" -> false
"no" -> false
"n" -> false
// If it's not a valid YAML boolean, return null
else -> null
}
private fun String.toBooleanOrNull(): Boolean? = when (lowercase()) {
"true" -> true
"false" -> false
else -> null
}
}