Sha256: 8bc9792419eab1bdba62105f8b75726769d2f00322dd22911fceaaf551ced9ba

Contents?: true

Size: 585 Bytes

Versions: 30

Compression:

Stored size: 585 Bytes

Contents

class Terraspace::Cloud::Api
  module Validate
    def validate(name, value)
      unless value =~ /^[\w-]*$/
        message = "ERROR: #{name}: only allows letters, numbers, dashes, and underscores"
      end
      if value =~ /^[-_]/ || value =~ /[-_]$/
        message = "ERROR: #{name}: no leading or trailing underscore or dash allowed"
      end
      if message
        puts message.color(:red)
        puts <<~EOL
          Please fix the configuration

          config/app.rb

             config.cloud.#{name} = '...'

        EOL
        exit 1
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.16 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.15 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.14 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.13 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.12 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.11 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.10 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.9 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.8 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.7 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.6 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.5 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.4 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.3 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.2 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.1 lib/terraspace/cloud/api/validate.rb
terraspace-2.2.0 lib/terraspace/cloud/api/validate.rb
terraspace-2.1.7 lib/terraspace/cloud/api/validate.rb
terraspace-2.1.6 lib/terraspace/cloud/api/validate.rb