Sha256: 53c574ea64fa0153e8de876a02f20951d8f6ef351a07c6b07c861dba8e1fc9d7
Contents?: true
Size: 849 Bytes
Versions: 19
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.JSON(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
19 entries across 19 versions & 1 rubygems