Background

The current Spring Framework's Assert class has the hasText method for checking whether individual objects are null or empty. However, to check multiple strings, each object must be validated separately, leading to longer code.

Problem

To validate multiple strings simultaneously, developers must write multiple calls to hasText. This approach is redundant and verbose, impacting code readability and maintainability.

Proposed Solution

To resolve this issue, I propose overloading methods that can validate an array of strings, similar to noNullElements(), to check multiple strings at once. By adding this new method, developers can validate multiple strings concisely and generate a single error message or separate messages for each invalid string.

Expected Outcome

If this proposal is implemented, developers can reduce code length, leading to improved readability.


Comment From: snicoll

@dukbong thanks for the proposal but, as stated in the Javadoc, Assert is mainly for internal use within the framework. We can consider this if we ever hit the situation you've described.