Sha256: 815d958fb15efde88ceef9eb5726f6afd7f3744a334bc030d86850c7c4b7caec

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 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)
        errors[key] << message unless condition
        condition
      end

      def assert_not_error(key)
        yield
        true
      rescue => ex
        errors[key] << ex.message
        false
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasti-form-5.0.0 lib/rasti/form/validable.rb
rasti-form-4.0.0 lib/rasti/form/validable.rb