Sha256: 12bb50243a95d967cfb128efd68a0178d6594222886aeab8db0a4a67810cbbbc

Contents?: true

Size: 676 Bytes

Versions: 4

Compression:

Stored size: 676 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 :scope, :errors
      
      def initialize(scope, errors)
        @scope = scope
        @errors = errors
      end

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

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rasti-form-1.1.1 lib/rasti/form/errors.rb
rasti-form-1.1.0 lib/rasti/form/errors.rb
rasti-form-1.0.3 lib/rasti/form/errors.rb
rasti-form-1.0.2 lib/rasti/form/errors.rb