@Test public void validateSpecialCharacters() { Throwable throwable = PathValidator.validate("/test/subpath/subpath2_with-and.dot/AND_UPPERCASE").blockingGet(); assertNull(throwable); }
public static Completable validate(String path) { if (path == null || "".equals(path)) { return Completable.error(new InvalidPathException("Path must not be null or empty")); } Matcher matcher = PATH_PATTERN.matcher(path); if (!matcher.matches()) { return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } if (!path.startsWith("/")) { return Completable.error(new InvalidPathException("Path must start with a '/'")); } if (path.contains(" return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } return Completable.complete(); }
PathValidator { public static Completable validate(String path) { if (path == null || "".equals(path)) { return Completable.error(new InvalidPathException("Path must not be null or empty")); } Matcher matcher = PATH_PATTERN.matcher(path); if (!matcher.matches()) { return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } if (!path.startsWith("/")) { return Completable.error(new InvalidPathException("Path must start with a '/'")); } if (path.contains(" return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } return Completable.complete(); } }
PathValidator { public static Completable validate(String path) { if (path == null || "".equals(path)) { return Completable.error(new InvalidPathException("Path must not be null or empty")); } Matcher matcher = PATH_PATTERN.matcher(path); if (!matcher.matches()) { return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } if (!path.startsWith("/")) { return Completable.error(new InvalidPathException("Path must start with a '/'")); } if (path.contains(" return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } return Completable.complete(); }  }
PathValidator { public static Completable validate(String path) { if (path == null || "".equals(path)) { return Completable.error(new InvalidPathException("Path must not be null or empty")); } Matcher matcher = PATH_PATTERN.matcher(path); if (!matcher.matches()) { return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } if (!path.startsWith("/")) { return Completable.error(new InvalidPathException("Path must start with a '/'")); } if (path.contains(" return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } return Completable.complete(); }  static Completable validate(String path); }
PathValidator { public static Completable validate(String path) { if (path == null || "".equals(path)) { return Completable.error(new InvalidPathException("Path must not be null or empty")); } Matcher matcher = PATH_PATTERN.matcher(path); if (!matcher.matches()) { return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } if (!path.startsWith("/")) { return Completable.error(new InvalidPathException("Path must start with a '/'")); } if (path.contains(" return Completable.error(new InvalidPathException("Path [" + path + "] is invalid")); } return Completable.complete(); }  static Completable validate(String path);  }