Sha256: 0fc96d1e6e16bd196d2135f194ff0b7b8bb57a9ca63bc83f06321c112ceed07b

Contents?: true

Size: 535 Bytes

Versions: 12

Compression:

Stored size: 535 Bytes

Contents

module Xeroizer
  module Record
    
    class Validator
      
      attr_reader :attribute
      attr_reader :options
      
      def initialize(attribute, options = {})
        @attribute = attribute
        @options = options
      end
  
      def validate(record)
        run_validator = true
        run_validator = false if options[:if] && !options[:if].call(record)
        run_validator = false if options[:unless] && options[:unless].call(record)
        valid?(record) if run_validator
      end
  
    end
    
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
xeroizer-0.3.5 lib/xeroizer/record/validators/validator.rb
xeroizer-0.3.4 lib/xeroizer/record/validators/validator.rb
xeroizer-0.3.3 lib/xeroizer/record/validators/validator.rb
xeroizer-0.3.2 lib/xeroizer/record/validators/validator.rb
xeroizer-0.3.1 lib/xeroizer/record/validators/validator.rb
xeroizer-0.3.0 lib/xeroizer/record/validators/validator.rb
xeroizer-0.2.2 lib/xeroizer/record/validators/validator.rb
xeroizer-0.2.1 lib/xeroizer/record/validators/validator.rb
xeroizer-0.2.0 lib/xeroizer/record/validators/validator.rb
xeroizer-0.1.3 lib/xeroizer/record/validators/validator.rb
xeroizer-0.1.2 lib/xeroizer/record/validators/validator.rb
xeroizer-0.1.0 lib/xeroizer/record/validators/validator.rb