public static InvalidHostNameProblem validateHost(final Object instance,
			final Annotation annotation, final Object target,
			final CharSequence name, final boolean reverse)
	{
		if (reverse)
		{
			try
			{
				InetAddress.getByName(name.toString());
				return null;
			}
			catch (final UnknownHostException e)
			{
				return new InvalidHostNameProblem(instance, annotation, target,
						name);
			}
		}

		final char[] chars = name.toString().toCharArray();

		if (chars[0] == '.' || chars[chars.length - 1] == '.')
		{
			return new InvalidHostNameProblem(instance, annotation, target,
					name);
		}

		boolean previousWasDot = false;

		for (final char c : chars)
		{
			if (c == '.')
			{
				// Two . back to back are invalid
				if (previousWasDot)
				{
					return new InvalidHostNameProblem(instance, annotation,
							target, name);
				}

				previousWasDot = true;
			}
			else if (isValidHostNameChar(c))
			{
				previousWasDot = false;
			}
			else
			// Not a valid host name char
			{
				return new InvalidHostNameProblem(instance, annotation, target,
						name);
			}
		}

		return null;
	}