Method: GraphQL::Schema::Validator::NumericalityValidator#initialize

Defined in:
lib/graphql/schema/validator/numericality_validator.rb

#initialize(greater_than: nil, greater_than_or_equal_to: nil, less_than: nil, less_than_or_equal_to: nil, equal_to: nil, other_than: nil, odd: nil, even: nil, within: nil, message: "%{validated} must be %{comparison} %{target}", null_message: Validator::AllowNullValidator::MESSAGE, **default_options) ⇒ NumericalityValidator

Returns a new instance of NumericalityValidator.

Parameters:

  • greater_than (Integer) (defaults to: nil)
  • greater_than_or_equal_to (Integer) (defaults to: nil)
  • less_than (Integer) (defaults to: nil)
  • less_than_or_equal_to (Integer) (defaults to: nil)
  • equal_to (Integer) (defaults to: nil)
  • other_than (Integer) (defaults to: nil)
  • odd (Boolean) (defaults to: nil)
  • even (Boolean) (defaults to: nil)
  • within (Range) (defaults to: nil)
  • message (String) (defaults to: "%{validated} must be %{comparison} %{target}")

    used for all validation failures



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/graphql/schema/validator/numericality_validator.rb', line 30

def initialize(
    greater_than: nil, greater_than_or_equal_to: nil,
    less_than: nil, less_than_or_equal_to: nil,
    equal_to: nil, other_than: nil,
    odd: nil, even: nil, within: nil,
    message: "%{validated} must be %{comparison} %{target}",
    null_message: Validator::AllowNullValidator::MESSAGE,
    **default_options
  )

  @greater_than = greater_than
  @greater_than_or_equal_to = greater_than_or_equal_to
  @less_than = less_than
  @less_than_or_equal_to = less_than_or_equal_to
  @equal_to = equal_to
  @other_than = other_than
  @odd = odd
  @even = even
  @within = within
  @message = message
  @null_message = null_message
  super(**default_options)
end