Class PatternFormat

java.lang.Object
com.networknt.schema.format.PatternFormat
All Implemented Interfaces:
Format

public class PatternFormat extends Object implements Format
Format using a regex pattern.
  • Method Details

    • of

      public static PatternFormat of(String name, String regex, String messageKey)
      Creates a pattern format.
      Parameters:
      name - the name
      regex - the regex pattern
      messageKey - the message key
      Returns:
      the pattern format
    • matches

      public boolean matches(ExecutionContext executionContext, String value)
      Description copied from interface: Format
      Determines if the value matches the format.

      This should be implemented for string node types.

      Specified by:
      matches in interface Format
      Parameters:
      executionContext - the execution context
      value - to match
      Returns:
      true if matches
    • getName

      public String getName()
      Description copied from interface: Format
      Gets the format name.
      Specified by:
      getName in interface Format
      Returns:
      the format name as referred to in a json schema format node.
    • getMessageKey

      public String getMessageKey()
      Description copied from interface: Format
      Gets the message key to use for the message.

      See jsv-messages.properties.

      The following are the arguments.
      {0} The format name
      {1} The input value

      Note that the default localized messages do not use the input value.

      Specified by:
      getMessageKey in interface Format
      Returns:
      the message key