Sha256: 2913d6ff522623a3f7fb91857de839548665939d1d9b566c52b8d4eb5461c494

Contents?: true

Size: 533 Bytes

Versions: 5

Compression:

Stored size: 533 Bytes

Contents

#
# This is a super simple replacement for ActiveSupport::Validations
#

module CertificateAuthority
  class Errors < Array
    def add(symbol, msg)
      self.push([symbol, msg])
    end
    def full_messages
      self.map {|i| i[0].to_s + ": " + i[1]}.join("\n")
    end
  end

  module Validations
    def valid?
      @errors = Errors.new
      validate
      errors.empty?
    end

    # must be overridden
    def validate
      raise NotImplementedError
    end

    def errors
      @errors ||= Errors.new
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
certificate_authority-1.1.0 lib/certificate_authority/validations.rb
certificate_authority-1.0.0 lib/certificate_authority/validations.rb
leap_cli-1.9.2 vendor/certificate_authority/lib/certificate_authority/validations.rb
leap_cli-1.9.1 vendor/certificate_authority/lib/certificate_authority/validations.rb
leap_cli-1.9 vendor/certificate_authority/lib/certificate_authority/validations.rb