Class ValidationRule

    • Constructor Detail

      • ValidationRule

        public ValidationRule​(ValidationRuleMetaData ruleInfo)
        Constructor.
        Parameters:
        ruleInfo -
    • Method Detail

      • setReporter

        public void setReporter​(IValidationProblemReporter reporter)
        Sets the validation problem reporter.
        Parameters:
        reporter -
      • report

        protected void report​(Node node,
                              String property,
                              Map<String,​String> messageParams)
        Called by validation rules to report an error.
        Parameters:
        node -
        property -
        messageParams -
      • reportIfInvalid

        protected void reportIfInvalid​(boolean isValid,
                                       Node node,
                                       String property,
                                       Map<String,​String> messageParams)
        Reports a validation error if the property is not valid.
        Parameters:
        isValid -
        node -
        property -
        messageParams -
      • reportIf

        protected void reportIf​(boolean condition,
                                Node node,
                                String property,
                                Map<String,​String> messageParams)
        Reports a validation error if the given condition is true.
        Parameters:
        condition -
        node -
        property -
        messageParams -
      • reportPathError

        protected void reportPathError​(Node node,
                                       Map<String,​String> messageParams)
        Utility function to report path related errors.
        Parameters:
        node -
        messageParams -
      • isDefined

        protected boolean isDefined​(Object propertyValue)
        Check if a property was defined.
        Parameters:
        propertyValue -
        Returns:
        {boolean}
      • isDefinition

        protected boolean isDefinition​(Node node)
        Check if the given node is a definition
        Parameters:
        node -
      • getMappedNodeName

        protected String getMappedNodeName​(Node node)
        Gets the name of a mapped node. This uses the traversal context to determine the name of the property (typically from a parent map) that points to this node.
        Parameters:
        node -
      • getDefinitionName

        protected String getDefinitionName​(Node node)
        Returns the name of the given definition. This should only be called *after* calling isDefinition() and only if it returns true. Otherwise the behavior of this method is undefined.
        Parameters:
        node -
      • getEncodingName

        protected String getEncodingName​(OpenApiEncoding encoding)
        Returns the name of an encoding. This can only be determined using the traversal context because the encoding name is the key for this encoding in the Map of encodings for a media type.
      • getPathTemplate

        protected String getPathTemplate​(OpenApiPathItem pathItem)
        Returns the path template for the given path item.
        Parameters:
        pathItem -
      • getStatusCode

        protected String getStatusCode​(OpenApiResponse response)
        Returns the status code of the given response.
      • getOperationMethod

        protected String getOperationMethod​(Operation operation)
        Returns the operation method (get, put, post, etc) for the given operation.
      • hasValue

        protected boolean hasValue​(Object propertyValue)
        Check if the property value exists (is not undefined and is not null).
        Parameters:
        propertyValue -
        Returns:
        {boolean}
      • isPathWellFormed

        protected boolean isPathWellFormed​(String pathTemplate)
        Checks the path template against the regular expression and returns match result.
        Parameters:
        pathTemplate -
        Returns:
        {boolean}
      • getPathSegments

        protected List<ValidationRule.PathSegment> getPathSegments​(String pathTemplate)
        Finds all occurences of path segment patterns in a path template.
        Parameters:
        pathTemplate -
        Returns:
        {PathSegment[]}
      • isNullOrUndefined

        protected boolean isNullOrUndefined​(Object value)
        Check if a value is either null or undefined.
        Parameters:
        value -
        Returns:
        {boolean}
      • isValidUrl

        protected boolean isValidUrl​(String propertyValue)
        Returns true only if the given value is a valid URL.
        Parameters:
        propertyValue -
        Returns:
        {boolean}
      • isValidUrlTemplate

        protected boolean isValidUrlTemplate​(String propertyValue)
        Returns true only if the given value is a valid URL template.
        Parameters:
        propertyValue -
      • isValidGFM

        protected boolean isValidGFM​(String propertyValue)
        Returns true only if the given value is valid GFM style markup.
        Parameters:
        propertyValue -
      • isValidCommonMark

        protected boolean isValidCommonMark​(String propertyValue)
        Returns true only if the given value is valid CommonMark style markup.
        Parameters:
        propertyValue -
      • isValidEmailAddress

        protected boolean isValidEmailAddress​(String propertyValue)
        Returns true only if the given value is a valid email address.
        Parameters:
        propertyValue -
      • isValidMimeType

        protected boolean isValidMimeType​(List<String> propertyValue)
        Returns true only if the given value is a valid mime-type.
        Parameters:
        propertyValue -
      • isValidEnumItem

        protected boolean isValidEnumItem​(String value,
                                          String[] items)
        Returns true if the given value is an item in the enum list.
        Parameters:
        value -
        items -
      • isValidForType

        protected boolean isValidForType​(Object value,
                                         Node node)
        Returns true if the given value is valid according to the schema provided.
        Parameters:
        value -
        node -
      • isValidHttpCode

        protected boolean isValidHttpCode​(String statusCode)
        Returns true if the given status code is a valid HTTP response code.
        Parameters:
        statusCode -
      • map

        protected Map<String,​String> map​(String... args)
        Turns a list of args into a map suitable for use as template arguments. The args must come in pairs of "key, value". For example: map("key1", "value1", "key2", Boolean.TRUE); That would return a Map two mappings.
      • array

        protected String[] array​(String... args)
        Creates an array.
        Parameters:
        args -
      • equals

        protected boolean equals​(Object value1,
                                 Object value2)
        Returns true if the two values are equal.
        Parameters:
        value1 -
        value2 -