Add isEmpty, isNotEmpty, and isBlank methods to ObjString, update tests and docs

This commit is contained in:
sergeych committed 2026-01-16 07:06:22 +03:00
1 parent d4bb186f85
commit 05e15e8e42
3 files changed
+76 -2

No files matched your search

@@ -301,6 +301,18 @@ data class ObjString(val value: String) : Obj() {
) {
thisAs<ObjString>().value.trim().let(::ObjString)
}
addFnDoc("isBlank", "Whether this string is empty or contains only whitespace characters.",
returns = type("lyng.Bool"), moduleName = "lyng.stdlib") {
ObjBool(thisAs<ObjString>().value.isBlank())
}
addFnDoc("isEmpty", "Whether this string is empty.",
returns = type("lyng.Bool"), moduleName = "lyng.stdlib") {
ObjBool(thisAs<ObjString>().value.isEmpty())
}
addFnDoc("isNotEmpty", "Whether this string is not empty.",
returns = type("lyng.Bool"), moduleName = "lyng.stdlib") {
ObjBool(thisAs<ObjString>().value.isNotEmpty())
}
addFnDoc(
name = "matches",
doc = "Whether this string matches the given regular expression or pattern string.",