isNotBlank
Returns true
if this char sequence is not empty and contains some characters except whitespace characters.
Returns true
if this char sequence is not empty and contains some characters except whitespace characters.
import java.util.Locale import kotlin.test.* fun main() { //sampleStart fun validateName(name: String): String { require(name.isNotBlank()) { "Name cannot be blank" } return name } println(validateName("Adam")) // Adam // validateName("") // will fail // validateName(" \t\n") // will fail //sampleEnd }
xxxxxxxxxx
fun validateName(name: String): String {
require(name.isNotBlank()) { "Name cannot be blank" }
return name
}
println(validateName("Adam")) // Adam
// validateName("") // will fail
// validateName(" \t\n") // will fail
Thanks for your feedback!