I was wondering how one could ensure that a Dry::Types::Struct attribute is a non-blank string.
I was able to get this behavior with
class MyClass < Dry::Types::Struct attribute :name, Types::Strict::String.constrained( format: /\S/) # contains at least one non-whitespace character end
However this triggers a very unclear error message & I did not find a way to specify a more specific error string.
MyClass.new(name: ' ') --> Dry::Types::StructError: [MyClass.new] " " (String) has invalid type for :name