Module: EasyType::Validators::Name

Defined in:
lib/easy_type/validators.rb

Overview

This validator validates if a name is free of whitespace and not empty. To use this validator, include it in a Puppet name definition.

Examples:


newparam(:name) do
  include ::EasyType::Validators::NameValidator

Raises:

  • (Puppet::Error)

    when the name is invalid

Class Method Summary collapse

Class Method Details

.unsafe_validate(value) ⇒ Object



38
39
40
41
# File 'lib/easy_type/validators.rb', line 38

def unsafe_validate(value)
  fail Puppet::Error, "Parameter #{name} may not contain whitespace: #{value}" if value =~ /\s/
  fail Puppet::Error, "Parameter #{name} may not be empty" if value.empty?
end