Sha256: 18683ac92fb2a13c9ea86dde598aca2c6fde16384518aa1b3a4d1a103bb4c7a7

Contents?: true

Size: 634 Bytes

Versions: 17

Compression:

Stored size: 634 Bytes

Contents

module Percheron
  module Validators
    class Stack

      def initialize(stack)
        @stack = stack
      end

      def valid?
        message = rules.return { |rule| send(rule) }
        message ? fail(Errors::StackInvalid, formatted_message(message)) : true
      end

      private

        attr_reader :stack

        def formatted_message(message)
          "Stack is invalid: #{message}"
        end

        def rules
          [ :validate_name ]
        end

        def validate_name
          return nil if !stack.name.nil? && stack.name.to_s.match(/\w{3,}/)
          'Name is invalid'
        end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
percheron-0.8.1 lib/percheron/validators/stack.rb
percheron-0.8.0 lib/percheron/validators/stack.rb
percheron-0.7.16 lib/percheron/validators/stack.rb
percheron-0.7.15 lib/percheron/validators/stack.rb
percheron-0.7.14 lib/percheron/validators/stack.rb
percheron-0.7.13 lib/percheron/validators/stack.rb
percheron-0.7.12 lib/percheron/validators/stack.rb
percheron-0.7.11 lib/percheron/validators/stack.rb
percheron-0.7.10 lib/percheron/validators/stack.rb
percheron-0.7.9 lib/percheron/validators/stack.rb
percheron-0.7.8 lib/percheron/validators/stack.rb
percheron-0.7.7 lib/percheron/validators/stack.rb
percheron-0.7.6 lib/percheron/validators/stack.rb
percheron-0.7.5 lib/percheron/validators/stack.rb
percheron-0.7.4 lib/percheron/validators/stack.rb
percheron-0.7.3 lib/percheron/validators/stack.rb
percheron-0.7.2 lib/percheron/validators/stack.rb