Sha256: 0d2d8bce1dd609d6b6fce95b7e8d0062380db8883ae8d4ffe5f00b64cec91f13

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

module Rasti
  class Form
    module Validable

      private

      def errors
        @errors ||= Hash.new { |hash, key| hash[key] = [] }
      end

      def validate!
        validate
        raise ValidationError.new(self, errors) unless errors.empty?
      end

      def validate
      end

      def assert(key, condition, message)
        return true if condition
        
        errors[key] << message
        false
      end

      def assert_not_error(key)
        yield
        true
      rescue => error
        assert key, false, error.message
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasti-form-3.1.2 lib/rasti/form/validable.rb
rasti-form-3.1.1 lib/rasti/form/validable.rb
rasti-form-3.1.0 lib/rasti/form/validable.rb