Reusing schema by switch required to optionsl


#1

I do have these to schema and beside the required and optional they are the same. the reason is when creating this object all of the mare required but to patch the object any given parameter is OK.

 Dry::Validation.Schema do
    required(:name).filled(:str?)
    required(:begin_date).filled(:date?)
    required(:energyprice_cents_per_kilowatt_hour).filled(:float?)
    required(:baseprice_cents_per_month).filled(:int?)
  end

  Dry::Validation.Schema  do
    optional(:name).filled(:str?)
    optional(:begin_date).filled(:date?)
    optional(:energyprice_cents_per_kilowatt_hour).filled(:float?)
    optional(:baseprice_cents_per_month).filled(:int?)
  end

is there a ‘dryer’ way ?