Sha256: 84761012b17e553e4cfd84a54f5f21dd2fe2906d1bebbd913cca83ec0a6f23bd
Contents?: true
Size: 849 Bytes
Versions: 11
Compression:
Stored size: 849 Bytes
Contents
require 'dry/validation/messages/i18n' require 'i18n' RSpec.describe 'Defining base schema class' do subject(:schema) do Dry::Validation.Form(BaseSchema) do required(:email).filled(:email?) end end before do class BaseSchema < Dry::Validation::Schema configure do |config| config.messages_file = SPEC_ROOT.join('fixtures/locales/en.yml') config.messages = :i18n end def email?(value) true end define! do required(:name).filled end end end after do Object.send(:remove_const, :BaseSchema) end it 'inherits predicates' do expect(schema).to respond_to(:email?) end it 'inherits rules' do expect(schema.('name' => '').messages).to eql( name: ['must be filled'], email: ['is missing', 'must be an email'] ) end end
Version data entries
11 entries across 11 versions & 1 rubygems