How to use array of user defined objects in dry-struct

I am trying to switch from virtus to dry-struct on a project but I have trouble finding how to use array of custom types, can someone point me in the right direction ?

require ‘dry-types’
require ‘dry-struct’

module Types
include Dry::Types.module

class User < Dry::Struct
attribute :name, Types::String
attribute :tags, Types::Array[Types::String]

class Group < Dry::Struct
attribute :users, Types::Array[User]

u1 = “John”, tags: [‘one’, ‘tw’])
u2 = “Alice”, tags: [‘one’])

g = [u1, u2])
p g

This fails when trying to create the group with this error:
(Array) has invalid type for :users violates constraints (can’t convert Array into Hash failed) (Dry::Struct::Error)

Does attribute :users, Types::Strict::Array.of(User) work?

Thanks, it works :slight_smile: