All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.management.domain.group.GroupNameValidator Maven / Gradle / Ivy

There is a newer version: 2.8.0
Show newest version
package pl.allegro.tech.hermes.management.domain.group;

import java.util.regex.Pattern;
import pl.allegro.tech.hermes.management.domain.GroupNameIsNotAllowedException;

class GroupNameValidator {

  private final Pattern allowedPattern;

  public GroupNameValidator(String allowedRegex) {
    this.allowedPattern = Pattern.compile(allowedRegex);
  }

  public void requireValid(String groupName) {
    if (!allowedPattern.matcher(groupName).matches()) {
      throw new GroupNameIsNotAllowedException(
          String.format("Group name should match pattern %s", allowedPattern));
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy