InputValidator

public class InputValidator extends BaseValidator implements GracieValidator {
    
    public InputValidator() {
        
    }
    
    /**
     * Return true when the input text is not empty
     * @param inputText          Input string text
     * @return boolean           Return true when the input text is not empty, otherwise return false.
     */
    public static boolean isNotEmpty(String inputText) {
        return !Util.isEmpty(inputText);
    }
    
    /**
     * Return true when the input text is not empty
     * @param inputText          Input string text
     * @param fieldErrorParam    Field error tag parameter
     * @param fieldErrorMessage  Field error message
     * @return boolean           Return true when the input text is not empty, otherwise return false.
     */
    public static boolean isNotEmpty(String inputText, String fieldErrorParam, String fieldErrorMessage) {
        boolean isValid = InputValidator.isNotEmpty(inputText);
        
        if (!isValid) {
            addFieldErrorMessage(fieldErrorParam, fieldErrorMessage);
        }
        
        return isValid;
    }
    
    /**
     * Return true when the input text is not empty
     * @param inputText          Input string text
     * @param fieldErrorParam    Field error tag parameter
     * @param bundle             Language property file id
     * @param key                Message key
     * @param defaultMessage     Default message
     * @param arguments          The arguments of message
     * @return boolean           Return true when the input text is not empty, otherwise return false.
     */
    public static boolean isNotEmpty(String inputText, String fieldErrorParam, 
            String bundle, String key, String defaultMessage, String[] arguments) {
        boolean isValid = InputValidator.isNotEmpty(inputText);
        
        if (!isValid) {
            String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments);
            addFieldErrorMessage(fieldErrorParam, fieldErrorMessage);
        }
        
        return isValid;
    }

	public boolean isValid(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) {
		return InputValidator.isNotEmpty(inputText, fieldErrorParam, bundle, key, defaultMessage, arguments);
	}

	public boolean isValid(String inputText, String fieldErrorParam, String fieldErrorMessage) {
		return InputValidator.isNotEmpty(inputText, fieldErrorParam, fieldErrorMessage);
	}

	public boolean isValid(String inputText) {
		return InputValidator.isNotEmpty(inputText);
	}
	
	public boolean isValid(String inputText, Object[] objs) {
		return isValid(inputText);
	}
    
}

 

你可能感兴趣的:(Java,fieldvalidation)