Sha256: ac8d9f6a94b2b2b55fa1fa7f7348f3ffd021a01f639d8d81288963f23bdf7556

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module Percheron
  module Validators
    class Stack

      def initialize(stack)
        @stack = stack
      end

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

        if message
          fail Errors::StackInvalid, message
        else
          true
        end
      end

      private

        attr_reader :stack

        def rules
          [ :validate_name ]
        end

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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percheron-0.7.1 lib/percheron/validators/stack.rb
percheron-0.7.0 lib/percheron/validators/stack.rb