Sha256: a9a94c90ef6617c250eab88ca795d264ddc6e5df9d3b63f5d3276f854a38d5a9
Contents?: true
Size: 571 Bytes
Versions: 19
Compression:
Stored size: 571 Bytes
Contents
require 'spec_helper' describe 'custom block validator' do Parametric.policy :validate_if do eligible do |options, value, key, payload| options.all? do |key, value| payload[key] == value end end end it 'works if I just define an :eligible block' do schema = Parametric::Schema.new do field(:name).policy(:validate_if, age: 40).present field(:age).type(:integer) end expect(schema.resolve(age: 30).errors.any?).to be false expect(schema.resolve(age: 40).errors.any?).to be true # name is missing end end
Version data entries
19 entries across 19 versions & 1 rubygems