Sha256: fd949e240019a2d2a12259069e57e0d0d9fcce1c1b69c72bf8c8cb81a0697adb

Contents?: true

Size: 883 Bytes

Versions: 27

Compression:

Stored size: 883 Bytes

Contents

module Foobara
  module BuiltinTypes
    module Number
      module SupportedValidators
        class Min < TypeDeclarations::Validator
          class BelowMinimumError < Foobara::Value::DataError
            class << self
              def context_type_declaration
                {
                  value: :number,
                  min: :number
                }
              end
            end
          end

          def min
            declaration_data
          end

          def validation_errors(value)
            if value < min
              build_error(value)
            end
          end

          def error_message(value)
            "Below minimum allowed. #{value} is less than #{min}"
          end

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.6 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.5 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.4 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.3 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.2 projects/builtin_types/src/number/supported_validators/min.rb
foobara-0.0.1 projects/builtin_types/src/number/supported_validators/min.rb