Tabnine Logo
RegexValidator
Code IndexAdd Tabnine to your IDE (free)

How to use
RegexValidator
in
co.elastic.apm.agent.configuration.validation

Best Java code snippets using co.elastic.apm.agent.configuration.validation.RegexValidator (Showing top 3 results out of 315)

origin: elastic/apm-agent-java

/**
 * Constructs a {@link RegexValidator} which validates a string based on a {@link Pattern}
 *
 * @param regex the regular expression which should be used to validate an input string
 * @return a {@link RegexValidator} which validates a string based on a {@link Pattern}
 */
public static RegexValidator of(String regex) {
  return new RegexValidator(regex, "Value \"{0}\" does not match regex {1}");
}
origin: elastic/apm-agent-java

  @Test
  void testRegexValidator() {
    SoftAssertions.assertSoftly(softly -> {
      softly.assertThatCode(() -> RegexValidator.of("foo").assertValid("foo")).doesNotThrowAnyException();
      // checking for nullness is not the responsibility of the validator, but it must be null safe
      softly.assertThatCode(() -> RegexValidator.of("foo").assertValid(null)).doesNotThrowAnyException();
      softly.assertThatCode(() -> RegexValidator.of("foo").assertValid("bar"))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("Value \"bar\" does not match regex foo");
      softly.assertThatCode(() -> RegexValidator.of("foo", "{0} is not {1}").assertValid("bar"))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("bar is not foo");
    });
  }
}
origin: elastic/apm-agent-java

/**
 * Constructs a {@link RegexValidator} which validates a string based on a {@link Pattern}
 *
 * @param regex               the regular expression which should be used to validate an input string
 * @param errorMessagePattern a error message format pattern. The placeholder {@code {0}} contains the actual value,
 *                            while the placeholder {@code {1}} represents the regex.
 * @return a {@link RegexValidator} which validates a string based on a {@link Pattern}
 */
public static RegexValidator of(String regex, String errorMessagePattern) {
  return new RegexValidator(regex, errorMessagePattern);
}
co.elastic.apm.agent.configuration.validationRegexValidator

Most used methods

  • <init>
  • assertValid
  • of
    Constructs a RegexValidator which validates a string based on a Pattern

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now