Interface ValidationStatement

    • Method Detail

      • execute

        @NotNull
        @NotNull ValidationInfo execute()
        The implementation must contain any validation logic. If the validation fails return a ValidationInfo with a message, which describes the error. Use the ValidationInfo.invalid(String) function in this case.
        If the validation was successful you can use the ValidationInfo.valid() function. This creates an information object with no message (usually the message is not important if the validation succeed, but it may help with debugging).
        Example:
        
         public ValidationInfo validate(){
             String name = unbindName();
             if (name.isBlank()){
                 return ValidationInfo.invalid("Name is blank");
             }
             return ValidationInfo.valid();
         }
         
        Statements can be grouped and chained by using a Validator
        Returns:
        The information if the validation succeed or not. Check the ValidationInfo.getMessage() if the validation failed. Returning null will result in a NullPointerException