class Objecheck::Validator::SatisfyRule

SatisfyRule validates objects by given Proc

Public Class Methods

new(_validator, pred) click to toggle source
# File lib/objecheck/validator/satisfy_rule.rb, line 20
def initialize(_validator, pred)
  @pred = pred
end
schema() click to toggle source
# File lib/objecheck/validator/satisfy_rule.rb, line 28
def self.schema
  [{ respond_to: %i[call] }]
end

Public Instance Methods

validate(target, collector) click to toggle source
# File lib/objecheck/validator/satisfy_rule.rb, line 24
def validate(target, collector)
  collector.add_error("should satisfy #{@pred.inspect}") if !@pred.call(target)
end