Sha256: 364d32c95121340ee1dc5d9fdde334154918cf9932153135fd1ab1d8c1b5d3f2

Contents?: true

Size: 576 Bytes

Versions: 15

Compression:

Stored size: 576 Bytes

Contents

module Percheron
  module Validators
    class Stack

      def initialize(stack)
        @stack = stack
      end

      def valid?
        message = rules.return { |rule| send(rule) }

        if message
          raise Errors::StackInvalid.new(message)
        else
          true
        end
      end

      private

        attr_reader :stack

        def rules
          [
            :validate_name
          ]
        end

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

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
percheron-0.6.4 lib/percheron/validators/stack.rb
percheron-0.6.3 lib/percheron/validators/stack.rb
percheron-0.6.2 lib/percheron/validators/stack.rb
percheron-0.6.1 lib/percheron/validators/stack.rb
percheron-0.6.0 lib/percheron/validators/stack.rb
percheron-0.5.0 lib/percheron/validators/stack.rb
percheron-0.4.0 lib/percheron/validators/stack.rb
percheron-0.3.2 lib/percheron/validators/stack.rb
percheron-0.3.1 lib/percheron/validators/stack.rb
percheron-0.3.0 lib/percheron/validators/stack.rb
percheron-0.2.4 lib/percheron/validators/stack.rb
percheron-0.2.3 lib/percheron/validators/stack.rb
percheron-0.2.2 lib/percheron/validators/stack.rb
percheron-0.2.1 lib/percheron/validators/stack.rb
percheron-0.2.0 lib/percheron/validators/stack.rb