Sha256: 9d3debadd1ca50e498870fc51fcca3d6311e504bffc61f387cf71b31697943be

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 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

        key(: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

4 entries across 4 versions & 1 rubygems

Version Path
dry-validation-0.7.4 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.7.3 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.7.2 spec/integration/schema/macros/confirmation_spec.rb
dry-validation-0.7.1 spec/integration/schema/macros/confirmation_spec.rb