Sha256: 2f9de7da2561784d2cfc0ad994292970a09525644f71201a6e02beec03697c33

Contents?: true

Size: 1020 Bytes

Versions: 26

Compression:

Stored size: 1020 Bytes

Contents

RSpec.describe 'Macros #confirmation' do
  describe 'with a maybe password with min-size specified' do
    subject(:schema) do
      Dry::Validation.Schema do
        configure do
          config.input_processor = :sanitizer

          def self.messages
            Messages.default.merge(
              en: { errors: { password_confirmation: 'does not match' } }
            )
          end
        end

        required(:password).maybe(min_size?: 3).confirmation
      end
    end

    it 'passes when values are equal' do
      expect(schema.(password: 'foo', password_confirmation: 'foo')).to be_success
    end

    it 'fails when source value is invalid' do
      expect(schema.(password: 'fo', password_confirmation: nil).messages).to eql(
        password: ['size cannot be less than 3']
      )
    end

    it 'fails when values are not equal' do
      expect(schema.(password: 'foo', password_confirmation: 'fo').messages).to eql(
        password_confirmation: ['does not match']
      )
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dry-validation-0.9.4 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.9.3 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.9.2 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.9.1 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.9.0 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.8.0 spec/integration/schema/macros/confirmation_spec.rb