public static String validateRequired ( final InputComponent < ? , ? > input ) { String requiredMessage = null ; if ( input . isEnabled ( ) && input . isRequired ( ) && ! InputComponents . hasValue ( input ) ) { requiredMessage = input . getRequiredMessage ( ) ; if ( Strings . isNullOrEmpty ( requiredMessage ) ) { String labelValue = input . getLabel ( ) == null ? input . getName ( ) : input . getLabel ( ) ; // Chop : off if ( labelValue . endsWith ( COLON ) ) { labelValue = labelValue . substring ( 0 , labelValue . length ( ) - 1 ) ; } requiredMessage = labelValue + " must be specified." ; } } return requiredMessage ; }
Validate if an required and enabled input has a value . If not return the error message .