toNotBlankStringOrThrow
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
Content copied to clipboard
You can use the toNotBlankStringOrNull function for returning null
instead of throwing an IllegalArgumentException when this string is blank.