Pihentagy
12/12/2025, 8:10 AM.isNotNull(), but no .isNotNullOrEmpty() for CharSequence? ?Joffrey
12/12/2025, 8:15 AMisNotNullOrEmpty() is equivalent to isNotNull, though, because empty strings are not null. Did you mean isNotNullAndNotEmpty()?Joffrey
12/12/2025, 8:16 AM!isNullOrEmpty(), the alternative seems either more verbose or more confusingPihentagy
12/12/2025, 8:17 AMJoffrey
12/12/2025, 8:20 AMJoffrey
12/12/2025, 8:21 AMisNeitherNullNorEmpty 😁James Richardson
12/12/2025, 8:52 AMfun String.whateverIWant(): Boolean = TODO("gotta think of something")
it doesn't have to go into the standard library, which creates a maintenance burden forever, you can tailor things to whatever you want. its easy to go overboard on these so do be thoughtful though!Rob Elliot
12/12/2025, 9:36 AMField subtype of CharSequence which guarantees:
• not empty
• no leading or trailing whitespace
• no new line characters
A sort of half-way house between String and a specific microtype... then your cases for a reference of type Field? are reduced to null / not null, because empty and blank are impossible.
Seems to me there's a lot of code out there which is implicitly assuming a String typed reference adheres to those invariants.loke
12/12/2025, 11:22 AMCharSequence can be mutable.Rob Elliot
12/12/2025, 11:37 AMString is a subtype of CharSequence, and String is immutable.loke
12/12/2025, 11:48 AMCharSequence satisfying these conditions would implicitly be a field.Rob Elliot
12/12/2025, 11:55 AMCharSequence to Field.
Argument against is that wherever you need it you probably have other validation requirements too (you almost certainly don't want it to be of potentially infinite length, for instance), so you arguably should be specifying a more specific String wrapping microtype.
Argument for is that loads of people can't be bothered to create String wrapping microtypes at all, they just use String, but might be persuadable to use a stdlib type of Field which would save a lot of empty / blank checking and redundant trimming or forgetting to trim.marlonlom
12/12/2025, 10:27 PMisNotBlank() ?