Dry::Validation Schema Template Structure


#1

Is it possible to define a base schema for standard structure and reuse it by nesting another schema in a specific place? For example:

BaseForm = Dry::Validation.Schema do
  configure { config.input_processor = :sanitizer }
  required(:data).schema do
    required(:type).filled
    required(:attributes).schema do
      [CompanyForm CONTENTS HERE]
    end
  end
end

CompanyForm = Dry::Validation.Schema(BaseForm) do
  required(:name).filled
  required(:organization).filled
end

#2

You can pass another schema into schema method in the DSL.