Class: Dry::Validation::InputProcessorCompiler::JSON

Inherits:
Dry::Validation::InputProcessorCompiler show all
Defined in:
lib/dry/validation/input_processor_compiler/json.rb

Constant Summary collapse

PREDICATE_MAP =
{
  default: 'string',
  none?: 'json.nil',
  bool?: 'bool',
  str?: 'string',
  int?: 'integer',
  float?: 'float',
  decimal?: 'json.decimal',
  date?: 'json.date',
  date_time?: 'json.date_time',
  time?: 'json.time'
}.freeze
CONST_MAP =
{
  NilClass => 'nil',
  String => 'string',
  Integer => 'integer',
  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

Constants inherited from Dry::Validation::InputProcessorCompiler

DEFAULT_TYPE_NODE

Instance Attribute Summary

Attributes inherited from Dry::Validation::InputProcessorCompiler

#type_compiler

Instance Method Summary collapse

Methods inherited from Dry::Validation::InputProcessorCompiler

#call, #constructor, #initialize, #schema_ast, #type, #visit, #visit_and, #visit_each, #visit_implication, #visit_key, #visit_not, #visit_or, #visit_predicate, #visit_rule, #visit_schema, #visit_set, #visit_type, #visit_val

Constructor Details

This class inherits a constructor from Dry::Validation::InputProcessorCompiler

Instance Method Details

#array_node(members) ⇒ Object



40
41
42
# File 'lib/dry/validation/input_processor_compiler/json.rb', line 40

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

#hash_node(schema) ⇒ Object



36
37
38
# File 'lib/dry/validation/input_processor_compiler/json.rb', line 36

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

#identifierObject



32
33
34
# File 'lib/dry/validation/input_processor_compiler/json.rb', line 32

def identifier
  :json
end