Skip to content

Can't set rule for array of hashes #603

@spazer5

Description

@spazer5
class PropsContract < Dry::Validation::Contract
  json do
    required(:contacts).value(:array, min_size?: 1).each do
      hash do
        required(:name).filled(:string)
        required(:email).filled(:string)
        required(:phone).filled(:string)
      end
    end
  end

  rule("contacts.email").validate(:email_format)
end

This errors out: Dry::Validation::InvalidKeysError: PropsContract.rule specifies keys that are not defined by the schema: ["contacts.email"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions