Sha256: 58b5d9b03202ebe0405ebe281beb1109c4b06a748468b71856326c1de76f83a6

Contents?: true

Size: 875 Bytes

Versions: 26

Compression:

Stored size: 875 Bytes

Contents

module Foobara
  module BuiltinTypes
    module Number
      module SupportedValidators
        class Max < TypeDeclarations::Validator
          class MaxExceededError < Foobara::Value::DataError
            class << self
              def context_type_declaration
                {
                  value: :number,
                  max: :number
                }
              end
            end
          end

          def max
            declaration_data
          end

          def validation_errors(value)
            if value > max
              build_error(value)
            end
          end

          def error_message(value)
            "Max exceeded. #{value} is larger than #{max}"
          end

          def error_context(value)
            {
              value:,
              max:
            }
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.25 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.24 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.23 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.22 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.21 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.20 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.19 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.18 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.17 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.16 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.15 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.14 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.13 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.12 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.11 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.10 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.9 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.8 projects/builtin_types/src/number/supported_validators/max.rb
foobara-0.0.7 projects/builtin_types/src/number/supported_validators/max.rb