Sha256: 2c3b6af0a42af6981f7aad6e1cfafc402e6b03729976682e2fd3645cff5c240e

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 Bytes

Contents

module Rasti
  class Form
    
    class CastError < StandardError

      attr_reader :type, :value

      def initialize(type, value)
        @type = type
        @value = value
      end

      def message
        "Invalid cast: #{display_value} -> #{type}"
      end

      private

      def display_value
        value.is_a?(::String) ? "'#{value}'" : value.inspect
      end

    end


    class ValidationError < StandardError

      attr_reader :errors
      
      def initialize(errors)
        @errors = errors
      end

      def message
        "Validation error: #{JSON.dump(errors)}"
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasti-form-1.0.1 lib/rasti/form/errors.rb
rasti-form-1.0.0 lib/rasti/form/errors.rb
rasti-form-0.1.0 lib/rasti/form/errors.rb