Class List Method List File List

# Class: VertxWebApiContract::ParameterValidationRule

Inherits:
  Object
  - Object
  - VertxWebApiContract::ParameterValidationRule
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb

## Overview

This function is an inner wrapper for ParameterTypeValidator inside ValidationHandler parameter maps. Don't instantiate this class, if you want to add custom ParameterTypeValidator to a parameter use functions in HTTPRequestValidationHandler

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (true, false) allow_empty_value?
  allowEmptyValue is used in query, header, cookie and form parameters.
- - (String) get_name
  This function return the name of the parameter expected into parameter lists.
- - (true, false) optional?
  Return true if parameter is optional.
- - (::VertxWebApiContract::ParameterTypeValidator) parameter_type_validator
  Return ParameterTypeValidator instance used inside this parameter validation rule.
- - (::VertxWebApiContract::RequestParameter) validate_array_param(value = nil)
  This function will be called when there is a List that need to be validated.
- - (::VertxWebApiContract::RequestParameter) validate_single_param(value = nil)
  This function will be called when there is only a string as parameter.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    21
    22
    23
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 21

    def @@j_api_type.accept?(obj)
      obj.class == ParameterValidationRule
    end

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 30

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    33
    34
    35
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 33

    def self.j_class
      Java::IoVertxExtWebApiValidation::ParameterValidationRule.java_class
    end

### + (`Object`) unwrap(obj)

    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 27

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    24
    25
    26
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 24

    def @@j_api_type.wrap(obj)
      ParameterValidationRule.new(obj)
    end

## Instance Method Details

### - (`true`, `false`) allow_empty_value?

allowEmptyValue is used in query, header, cookie and form parameters. This is its behaviour:

1. During validation, the ValidationHandler check if there's a parameter with combination of location and name as defined in this rule
2. If it not exists, It will check allowEmptyValue and if there's a default value set inside ParameterTypeValidator:

- If this condition it's true, It marks as validated the parameter and returns the default value (inside RequestParameter)
- If this condition it's false, It throws ValidationException

3. If the parameter exists, It checks if parameter is null or empty string:

- If allowEmptyValue it's true, It marks as validated the parameter and returns the default value if it exists (inside RequestParameter)
- If allowEmptyValue it's false, It throws ValidationException

Returns:

- (`true`, `false`) —
  value of allowEmptyValue

Raises:

- (`ArgumentError`)

    99
    100
    101
    102
    103
    104
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 99

    def allow_empty_value?
      if !block_given?
        return @j_del.java_method(:allowEmptyValue, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling allow_empty_value?()"
    end

### - (`String`) get_name

This function return the name of the parameter expected into parameter lists

Returns:

- (`String`) —
  name of the parameter

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 38

    def get_name
      if !block_given?
        return @j_del.java_method(:getName, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling get_name()"
    end

### - (`true`, `false`) optional?

Return true if parameter is optional

Returns:

- (`true`, `false`) —
  true if is optional, false otherwise

Raises:

- (`ArgumentError`)

    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 66

    def optional?
      if !block_given?
        return @j_del.java_method(:isOptional, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling optional?()"
    end

### - (`::VertxWebApiContract::ParameterTypeValidator`) parameter_type_validator

Return ParameterTypeValidator instance used inside this parameter validation rule

Returns:

- (`::VertxWebApiContract::ParameterTypeValidator`)

Raises:

- (`ArgumentError`)

    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 74

    def parameter_type_validator
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:parameterTypeValidator, []).call(),::VertxWebApiContract::ParameterTypeValidator)
      end
      raise ArgumentError, "Invalid arguments when calling parameter_type_validator()"
    end

### - (`::VertxWebApiContract::RequestParameter`) validate_array_param(value = nil)

This function will be called when there is a List that need to be validated. It must check if array is expected or not. It will throw a ValidationError in an error during validation occurs

Parameters:

- value (`Array<String>`) (defaults to: `nil`) —
  list of values that will be validated

Returns:

- (`::VertxWebApiContract::RequestParameter`)

Raises:

- (`ArgumentError`)

    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 58

    def validate_array_param(value=nil)
      if value.class == Array && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:validateArrayParam, [Java::JavaUtil::List.java_class]).call(value.map { |element| element }),::VertxWebApiContract::RequestParameter)
      end
      raise ArgumentError, "Invalid arguments when calling validate_array_param(#{value})"
    end

### - (`::VertxWebApiContract::RequestParameter`) validate_single_param(value = nil)

This function will be called when there is only a string as parameter. It will throw a ValidationError in an error during validation occurs

Parameters:

- value (`String`) (defaults to: `nil`) —
  list of values that will be validated

Returns:

- (`::VertxWebApiContract::RequestParameter`)

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/parameter_validation_rule.rb', line 48

    def validate_single_param(value=nil)
      if value.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:validateSingleParam, [Java::java.lang.String.java_class]).call(value),::VertxWebApiContract::RequestParameter)
      end
      raise ArgumentError, "Invalid arguments when calling validate_single_param(#{value})"
    end