Interface FormatValidator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static FormatValidator NONE
      No-operation implementation (never throws {always returns Optional.empty()).
    • Method Summary

      Modifier and Type Method Description
      static FormatValidator forFormat​(java.lang.String formatName)
      Static factory method for FormatValidator implementations supporting the formatNames mandated by the json schema spec.
      default java.lang.String formatName()
      Provides the name of this format.
      java.util.Optional<java.lang.String> validate​(java.lang.String subject)
      Implementation-specific validation of subject.
    • Field Detail

      • NONE

        static final FormatValidator NONE
        No-operation implementation (never throws {always returns Optional.empty()).
    • Method Detail

      • forFormat

        static FormatValidator forFormat​(java.lang.String formatName)
        Static factory method for FormatValidator implementations supporting the formatNames mandated by the json schema spec.
        • date-time
        • email
        • hostname
        • uri
        • ipv4
        • ipv6
        Parameters:
        formatName - one of the 6 built-in formats.
        Returns:
        a FormatValidator implementation handling the formatName format.
      • validate

        java.util.Optional<java.lang.String> validate​(java.lang.String subject)
        Implementation-specific validation of subject. If a validation error occurs then implementations should return a programmer-friendly error message as a String wrapped in an Optional. If the validation succeeded then an empty optional should be returned.
        Parameters:
        subject - the string to be validated
        Returns:
        an Optional wrapping the error message if a validation error occured, otherwise an empty optional.
      • formatName

        default java.lang.String formatName()
        Provides the name of this format.

        Unless specified otherwise the SchemaLoader will use this name to recognize string schemas using this format.

        The default implementation of this method returns "unnamed-format". It is strongly recommended for implementations to give a more meaningful name by overriding this method.
        Returns:
        the format name.