Sha256: 93930e3025b1d22b0e89b14ffc14e8749f8de4a20383dc66b722ece0344a9d9e
Contents?: true
Size: 1013 Bytes
Versions: 71
Compression:
Stored size: 1013 Bytes
Contents
module RSpectacular module ActiveRecord module Matchers class PositivityMatcher < Shoulda::ActiveRecord::Matchers::ValidateNumericalityOfMatcher def matches?(positivitable) super(positivitable) disallows_zero_values && disallows_negative_values end def failure_message "Expected #{@attribute.to_s} to be a positive number, got: #{pretty_error_messages(@attribute)}" end def negative_failure_message "Expected #{@attribute.to_s} to be a negative number, got: #{pretty_error_messages(@attribute)}" end def disallows_negative_values disallows_value_of(-1) && disallows_value_of(-100) end def disallows_zero_values disallows_value_of(0) end def description "should be contain a positive number" end end def validate_positivity_of(date) PositivityMatcher.new(date) end end end end
Version data entries
71 entries across 71 versions & 1 rubygems