Sha256: 2bbf32171a4a29f4244048333663d4873e38dce2e8172319861916d934b11622

Contents?: true

Size: 1020 Bytes

Versions: 4

Compression:

Stored size: 1020 Bytes

Contents

module Dry
  module Validation
    class InputProcessorCompiler::JSON < InputProcessorCompiler
      PREDICATE_MAP = {
        default: 'string',
        none?: 'json.nil',
        bool?: 'bool',
        str?: 'string',
        int?: 'int',
        float?: 'float',
        decimal?: 'json.decimal',
        date?: 'json.date',
        date_time?: 'json.date_time',
        time?: 'json.time'
      }.freeze

      CONST_MAP = {
        NilClass => 'nil',
        String => 'string',
        Integer => 'int',
        Float => 'float',
        BigDecimal => 'json.decimal',
        Array => 'json.array',
        Hash => 'json.hash',
        Date => 'json.date',
        DateTime => 'json.date_time',
        Time => 'json.time',
        TrueClass => 'true',
        FalseClass => 'false'
      }.freeze

      def identifier
        :json
      end

      def hash_node(schema)
        [:json_hash, [schema, {}]]
      end

      def array_node(members)
        [:json_array, [members, {}]]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-validation-0.11.2 lib/dry/validation/input_processor_compiler/json.rb
dry-validation-0.12.0 lib/dry/validation/input_processor_compiler/json.rb
dry-validation-0.11.1 lib/dry/validation/input_processor_compiler/json.rb
dry-validation-0.11.0 lib/dry/validation/input_processor_compiler/json.rb