toNotBlankStringOrThrow

@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun String.toNotBlankStringOrThrow(): NotBlankString

Returns this string as a NotBlankString, or throws an IllegalArgumentException if this string is blank.

Here's some usage examples:

var result: NotBlankString = "hello world".toNotBlankStringOrThrow()
println(result) // hello world

" ".toNotBlankStringOrThrow() // IllegalArgumentException

You can use the toNotBlankStringOrNull function for returning null instead of throwing an IllegalArgumentException when this string is blank.