src/org/ohmage/validator/UserValidators.java
public static String validateUsername(final String username) 
			throws ValidationException {
		
		LOGGER.info("Validating that the username follows our conventions.");
		
		if(StringUtils.isEmptyOrWhitespaceOnly(username)) {
			return null;
		}
		
		if(USERNAME_PATTERN.matcher(username).matches()) {
			return username;
		}
		else {
			throw new ValidationException(
					ErrorCode.USER_INVALID_USERNAME, 
					"The username is invalid. " + USERNAME_REQUIREMENTS);
		}
	}
/**
	 * Validates that a given username follows our conventions. If it is null 
	 * or whitespace only, null is returned. If it doesn't follow our 
	 * conventions, a ValidationException is thrown. Otherwise, the username is
	 * passed back to the caller.
	 * 
	 * @param username The username to validate.
	 * 
	 * @return Returns null if the username is null or whitespace only. 
	 * 		   Otherwise, it returns the username.
	 * 
	 * @throws ValidationException Thrown if the username isn't null or 
	 * 							   whitespace only and doesn't follow our 
	 * 							   conventions.
	 */
Validates that a given username follows our conventions. If it is null
or whitespace only, null is returned. If it doesn't follow our
conventions, a ValidationException is thrown. Otherwise, the username is
passed back to the caller.

@param username The username to validate.

@return Returns null if the username is null or whitespace only.
Otherwise, it returns the username.

@throws ValidationException Thrown if the username isn't null or
whitespace only and doesn't follow our
conventions.
Validates that a given username follows our conventions . If it is null or whitespace only null is returned . If it doesn ' t follow our conventions a ValidationException is thrown . Otherwise the username is passed back to the caller . @param username The username to validate . @return Returns null if the username is null or whitespace only . Otherwise it returns the username . @throws ValidationException Thrown if the username isn ' t null or whitespace only and doesn ' t follow our conventions .
public static String validateUsername(final String username) 
			throws ValidationException {
		LOGGER.info("Validating that the username follows our conventions.");
		if(StringUtils.isEmptyOrWhitespaceOnly(username)) {
			return null;
		}
		if(USERNAME_PATTERN.matcher(username).matches()) {
			return username;
		}
		else {
			throw new ValidationException(
					ErrorCode.USER_INVALID_USERNAME, 
					"The username is invalid. " + USERNAME_REQUIREMENTS);
		}
	}
public static String validateUsername ( final String username ) throws ValidationException { LOGGER . info ( "Validating that the username follows our conventions." ) ; if ( StringUtils . isEmptyOrWhitespaceOnly ( username ) ) { return null ; } if ( USERNAME_PATTERN . matcher ( username ) . matches ( ) ) { return username ; } else { throw new ValidationException ( ErrorCode . USER_INVALID_USERNAME , "The username is invalid. " + USERNAME_REQUIREMENTS ) ; } }
Validates that a given username follows our conventions.
Validates that a given username follows our conventions .