Class: Roda::RodaPlugins::ParamsCheck::ApplicationContract

Inherits:
Dry::Validation::Contract
  • Object
show all
Defined in:
lib/zleb/plugins/params_check.rb

Overview

定义contract 来校验

Class Method Summary collapse

Class Method Details

.params(&block) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/zleb/plugins/params_check.rb', line 89

def self.params(&block)
  add_config_block = Proc.new do
    config.types = TypeContainer
    self.instance_eval(&block)
  end

  param_schema = Dry::Schema.Params(&add_config_block)
  extended_info = DrySchemaExtend::SchemaExtendEdInfo.define(&block)
  
  schema_info = DrySchemaExtend::SchemaInfoCompiler.new(param_schema)
  schema_info.call
  schema_info = schema_info.to_h
  
  @schema_info = extended_info.get_desc.deep_merge(schema_info[:children])
  
  super(&add_config_block)
end

.schema_infoObject



107
108
109
# File 'lib/zleb/plugins/params_check.rb', line 107

def self.schema_info
  @schema_info
end