class AlarmValidator {

    public void validateAlarm(final Alarm alarm) throws CerebroException {
        // Validate required fields
        if (StringUtils.isEmpty(alarm.getName())) {
            throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm name is required.");
        }

        if (StringUtils.isEmpty(alarm.getTarget()) || StringUtils.startsWithIgnoreCase(alarm.getTarget(), "*")) {
            throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm target is required.");
        }

        if (StringUtils.isEmpty(alarm.getWarn())) {
            throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm warning threshold is required.");
        }

        if (StringUtils.isEmpty(alarm.getError())) {
            throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm error threshold is required.");
        }
    }

}