Hi,
I’m trying to deal with optional and required field in my domain entity.
I have an Article with an required field ‘title’ and an optional field ‘title2’
class Article < Dry::Struct
constructor_type(:schema)
attribute :title, Types::Strict::String
attribute :title2, Types::String.optional
end
I want those behaviors :
Article.new # this should fail (miss title)
Article.new(title: 'ok') # should be success
Article.new(title: 'ok', title2: 'ok') # should be success
I tried multiple constructor_type, but I cannot found the right one.
Did I miss something ?