Sha256: 6cdf525a18c0bff358a54f3de85db01e7b385f41c1e6879f6d6a592adfdbee82

Contents?: true

Size: 870 Bytes

Versions: 26

Compression:

Stored size: 870 Bytes

Contents

module Foobara
  module BuiltinTypes
    module String
      module SupportedValidators
        class MaxLength < TypeDeclarations::Validator
          class MaxLengthExceededError < Foobara::Value::DataError
            class << self
              def context_type_declaration
                {
                  value: :string,
                  max_length: :integer
                }
              end
            end
          end

          def validation_errors(string)
            if string.length > max_length
              build_error(string)
            end
          end

          def error_message(_value)
            "Max length exceeded. Cannot be longer than #{max_length}"
          end

          def error_context(value)
            {
              value:,
              max_length:
            }
          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/string/supported_validators/max_length.rb
foobara-0.0.25 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.24 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.23 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.22 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.21 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.20 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.19 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.18 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.17 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.16 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.15 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.14 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.13 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.12 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.11 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.10 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.9 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.8 projects/builtin_types/src/string/supported_validators/max_length.rb
foobara-0.0.7 projects/builtin_types/src/string/supported_validators/max_length.rb