Sha256: cd82b443ad1dcd9b70fdf6afc9ae458591d580ad737b4f855a82ac82154d1dc8

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

RSpec.describe 'Macros #input' do
  subject(:schema) do
    Dry::Validation.Schema do
      input :hash?

      required(:foo).filled
    end
  end

  it 'passes when input is valid' do
    expect(schema.(foo: "bar")).to be_successful
  end

  it 'prepends a rule for the input' do
    expect(schema.(nil).messages).to eql(["must be a hash"])
  end

  it 'applies other rules when input has expected type' do
    expect(schema.(foo: '').messages).to eql(foo: ["must be filled"])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-validation-0.8.0 spec/integration/schema/macros/input_spec.rb